Refactor the way to set the theme from the cli.
This commit is contained in:
@@ -94,17 +94,16 @@ def build(source, destination, debug=False, verbose=False, force=False,
|
||||
sys.exit(1)
|
||||
settings = read_settings(config)
|
||||
|
||||
if source:
|
||||
settings['source'] = os.path.abspath(source)
|
||||
if destination:
|
||||
settings['destination'] = os.path.abspath(destination)
|
||||
for key in ('source', 'destination', 'theme'):
|
||||
arg = locals()[key]
|
||||
if arg is not None:
|
||||
settings[key] = os.path.abspath(arg)
|
||||
logger.info("%12s : %s", key.capitalize(), settings[key])
|
||||
|
||||
logger.info("Input : %s", settings['source'])
|
||||
if not settings['source'] or not os.path.isdir(settings['source']):
|
||||
logger.error("Input directory not found: %s", settings['source'])
|
||||
sys.exit(1)
|
||||
|
||||
logger.info("Output : %s", settings['destination'])
|
||||
if not os.path.relpath(settings['destination'],
|
||||
settings['source']).startswith('..'):
|
||||
logger.error("Output directory should be outside of the input "
|
||||
@@ -114,7 +113,7 @@ def build(source, destination, debug=False, verbose=False, force=False,
|
||||
locale.setlocale(locale.LC_ALL, settings['locale'])
|
||||
init_plugins(settings)
|
||||
|
||||
gal = Gallery(settings, theme=theme, ncpu=ncpu)
|
||||
gal = Gallery(settings, ncpu=ncpu)
|
||||
gal.build(force=force)
|
||||
|
||||
# copy extra files
|
||||
|
||||
@@ -416,9 +416,8 @@ class Album(UnicodeMixin):
|
||||
|
||||
class Gallery(object):
|
||||
|
||||
def __init__(self, settings, theme=None, ncpu=None):
|
||||
def __init__(self, settings, ncpu=None):
|
||||
self.settings = settings
|
||||
self.theme = theme
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.stats = {'image': 0, 'image_skipped': 0,
|
||||
'video': 0, 'video_skipped': 0}
|
||||
@@ -540,8 +539,7 @@ class Gallery(object):
|
||||
print('')
|
||||
|
||||
if self.settings['write_html']:
|
||||
writer = Writer(self.settings, theme=self.theme,
|
||||
index_title=self.albums['.'].title)
|
||||
writer = Writer(self.settings, index_title=self.albums['.'].title)
|
||||
|
||||
for album in self.albums.values():
|
||||
writer.write(album)
|
||||
|
||||
@@ -45,10 +45,10 @@ class Writer(object):
|
||||
|
||||
template_file = 'index.html'
|
||||
|
||||
def __init__(self, settings, theme=None, index_title=''):
|
||||
def __init__(self, settings, index_title=''):
|
||||
self.settings = settings
|
||||
self.output_dir = settings['destination']
|
||||
self.theme = theme or settings['theme']
|
||||
self.theme = settings['theme']
|
||||
self.index_title = index_title
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user