Ejemplo n.º 1
0
def get_config(args):
    config = {}
    if args.path:
        config['PATH'] = os.path.abspath(os.path.expanduser(args.path))
    if args.output:
        config['OUTPUT_PATH'] = \
            os.path.abspath(os.path.expanduser(args.output))
    if args.theme:
        abstheme = os.path.abspath(os.path.expanduser(args.theme))
        config['THEME'] = abstheme if os.path.exists(abstheme) else args.theme
    if args.delete_outputdir is not None:
        config['DELETE_OUTPUT_DIRECTORY'] = args.delete_outputdir
    if args.ignore_cache:
        config['LOAD_CONTENT_CACHE'] = False
    if args.cache_path:
        config['CACHE_PATH'] = args.cache_path
    if args.selected_paths:
        config['WRITE_SELECTED'] = args.selected_paths.split(',')
    if args.relative_paths:
        config['RELATIVE_URLS'] = args.relative_paths
    if args.port is not None:
        config['PORT'] = args.port
    if args.bind is not None:
        config['BIND'] = args.bind
    config['DEBUG'] = args.verbosity == logging.DEBUG
    config.update(coerce_overrides(args.overrides))

    return config
Ejemplo n.º 2
0
 def test_coerce_overrides(self):
     overrides = coerce_overrides({
         'ARTICLE_EXCLUDES': '["testexcl"]',
         'READERS': '{"foo": "bar"}',
         'STATIC_EXCLUDE_SOURCES': 'true',
         'THEME_STATIC_DIR': 'theme',
     })
     expected = {
         'ARTICLE_EXCLUDES': ["testexcl"],
         'READERS': {
             "foo": "bar"
         },
         'STATIC_EXCLUDE_SOURCES': True,
         'THEME_STATIC_DIR': 'theme',
     }
     self.assertDictEqual(overrides, expected)