Enhance detection of a theme directory.

This commit is contained in:
Simon Conseil
2015-09-01 00:24:39 +02:00
parent 9f0cf68b7b
commit ccea99ed36
3 changed files with 6 additions and 2 deletions

View File

@@ -132,7 +132,9 @@ def read_settings(filename=None):
# Make the paths relative to the settings file
paths = ['source', 'destination', 'watermark']
if os.path.isdir(join(settings_path, settings['theme'])):
if os.path.isdir(join(settings_path, settings['theme'])) and \
os.path.isdir(join(settings_path, settings['theme'],
'templates')):
paths.append('theme')
enc = locale.getpreferredencoding() if PY2 else None

View File

@@ -53,7 +53,8 @@ class Writer(object):
self.logger = logging.getLogger(__name__)
# search the theme in sigal/theme if the given one does not exists
if not os.path.exists(self.theme):
if not os.path.exists(self.theme) or \
not os.path.exists(os.path.join(self.theme, 'templates')):
self.theme = os.path.join(THEMES_PATH, self.theme)
if not os.path.exists(self.theme):
raise Exception("Impossible to find the theme %s" % self.theme)

View File

@@ -48,6 +48,7 @@ def test_theme_path(tmpdir):
"""Test that image size is swaped if needed."""
tmpdir.join('theme').mkdir()
tmpdir.join('theme').join('templates').mkdir()
conf = tmpdir.join('sigal.conf.py')
conf.write("""# -*- coding: utf-8 -*-