Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug and add some error message for hommization #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions flask_themes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ def __init__(self, path):
#: path.
self.path = os.path.abspath(path)

with open(os.path.join(self.path, 'info.json')) as fd:
self.info = i = json.load(fd)
try:
with open(os.path.join(self.path, 'info.json')) as fd:
try:
self.info = i = json.load(fd)
except ValueError, e:
raise path + ": Invalid json format."
except OSError, e:
raise path + ": Could not find `info.json`."

#: The theme's name, as given in info.json. This is the human
#: readable name.
Expand Down Expand Up @@ -167,7 +173,7 @@ def load_themes_from(path):
try:
t = Theme(os.path.join(path, basename))
except:
pass
raise
else:
if t.identifier == basename:
yield t
Expand Down Expand Up @@ -413,7 +419,10 @@ def active_theme(ctx):
@contextfunction
def global_theme_template(ctx, templatename, fallback=True):
theme = active_theme(ctx)
templatepath = '_themes/%s/%s' % (theme, templatename)
if USING_BLUEPRINTS:
templatepath = '%s/%s' % (theme, templatename)
else:
templatepath = '_themes/%s/%s' % (theme, templatename)
if (not fallback) or template_exists(templatepath):
return templatepath
else:
Expand Down