Refactoring: Moved default configuration to config module.

This commit is contained in:
Achim D. Brucker 2017-07-29 12:36:20 +01:00
parent 0b24fb15fe
commit eb0054b47d
2 changed files with 20 additions and 5 deletions

View File

@ -130,7 +130,21 @@ def db_file(archivedir, ext_id):
return os.path.join(archivedir, return os.path.join(archivedir,
get_local_archive_dir(ext_id), ext_id + ".sqlite") get_local_archive_dir(ext_id), ext_id + ".sqlite")
def jsloc_timeout(): def jsloc_timeout():
"""Maximum number of seconds for counting jsloc per extension.""" """Maximum number of seconds for counting jsloc per extension."""
return 600 return 600
def const_basedir():
"""Top-level directory for the extension crawler archive."""
return "archive"
def const_parallel_downloads():
"""Number of parallel downloads."""
return 36
def const_verbose():
"""Default verbosity."""
return True
def const_discover():
"""Default configuration of discovery mode"""
return False

View File

@ -29,6 +29,7 @@ from functools import reduce
from ExtensionCrawler.discover import get_new_ids from ExtensionCrawler.discover import get_new_ids
from ExtensionCrawler.archive import get_forum_ext_ids, get_existing_ids, update_extensions from ExtensionCrawler.archive import get_forum_ext_ids, get_existing_ids, update_extensions
from ExtensionCrawler.util import log from ExtensionCrawler.util import log
import ExtensionCrawler.config
# Script should run with python 3.4 or 3.5 # Script should run with python 3.4 or 3.5
assert sys.version_info >= (3, 4) and sys.version_info < (3, 6) assert sys.version_info >= (3, 4) and sys.version_info < (3, 6)
@ -168,10 +169,10 @@ def print_config(verbose, basedir, archive_dir, conf_dir, discover, parallel):
def parse_args(argv): def parse_args(argv):
"""Parse command line arguments. """ """Parse command line arguments. """
basedir = "archive" basedir = ExtensionCrawler.config.const_basedir()
parallel = 24 parallel = ExtensionCrawler.config.const_parallel_downloads()
verbose = True verbose = ExtensionCrawler.config.const_verbose()
discover = False discover = ExtensionCrawler.config.const_discover()
try: try:
opts, _ = getopt.getopt(argv, "hsda:p:", ["archive=", 'parallel=']) opts, _ = getopt.getopt(argv, "hsda:p:", ["archive=", 'parallel='])
except getopt.GetoptError: except getopt.GetoptError: