Skip to content

Commit

Permalink
update&cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
1xch committed Apr 7, 2014
1 parent b1c844e commit c953a7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 14 additions & 13 deletions flask_fleem/theme.py
Expand Up @@ -20,25 +20,24 @@ def __init__(self, path):
with open(os.path.join(self.path, 'info.yaml')) as fd:
self.info = i = yaml.load(fd)

if not all(k in i for k in ('name', 'application', 'identifier')):
if not all(k in i for k in ('name', 'identifier', 'application')):
raise AttributeError("""
Theme configuration MUST contain:\n
- name\n
- application\n
- identifier\n
theme configuration contained:
{}
- theme name\n
- theme identifier\n
- application identifier\n
theme configuration contained:{i}
""").format(i)

# The theme's human readable name, as given in info.yaml.
self.name = i.pop('name', 'No name provided')

# The application name given in the theme's info.yaml.
self.application = i.pop('application', 'No application provided')
self.name = i.pop('name')

# The theme's identifier. In most situations should match the name of
# the directory the theme is in.
self.identifier = i.pop('identifier', 'No identifier provided')
self.identifier = i.pop('identifier')

# The application name to associate them with application.
self.application = i.pop('application')

for k,v in iter(i.items()):
setattr(self, k, v)
Expand Down Expand Up @@ -79,9 +78,11 @@ def return_bundle(self, extension, resource_filter):
resources = self.theme_files_of(extension)
if resources:
manifest = "{} for theme {} == {}".format(extension, self.name, [r for r in resources])
return manifest, Bundle(*resources, output=resource_tag, filters=resource_filter)
bundle = Bundle(*resources, output=resource_tag, filters=resource_filter)
else:
return "No {} resources for {}".format(extension, self.name), None
manifest = "No {} resources for {}".format(extension, self.name)
bundle = None
return manifest, bundle

@cached_property
def static_path(self):
Expand Down
4 changes: 2 additions & 2 deletions flask_fleem/theme_manager.py
Expand Up @@ -121,7 +121,7 @@ def list_themes(self):
"""
This yields all the `Theme` objects, in sorted order.
"""
return sorted(iter(self.themes.values()), key=attrgetter('identifier'))
return sorted(self.themes.values(), key=attrgetter('identifier'))

def valid_app_id(self, app_id):
"""
Expand All @@ -135,7 +135,7 @@ def valid_app_id(self, app_id):

def register_theme_assets(self):
for t in self.list_themes:
for k,v in iter(self.extensions_filters.items()):
for k,v in self.extensions_filters.items():
manifest_entry, bundle = t.return_bundle(k,v)
if self.log:
self.app.logger.info("{}".format(manifest_entry))
Expand Down

0 comments on commit c953a7c

Please sign in to comment.