Skip to content

Commit

Permalink
avoid doing lookup in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Jan 17, 2017
1 parent 7766666 commit b24aeb7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pyramid/config/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ def add_translation_dirs(self, *specs):
earlier in the list trump ones later in the list).
"""
directories = []
introspectables = []
resolver = AssetResolver(self.package_name)

def register():
directories = []
resolver = AssetResolver(self.package_name)

# defer spec resolution until register to allow for asset
# overrides to take place in an earlier config phase
for spec in specs[::-1]: # reversed
Expand All @@ -91,13 +92,11 @@ def register():
introspectables.append(intr)
directories.append(directory)

tdirs = self.registry.queryUtility(ITranslationDirectories)
if tdirs is None:
tdirs = []
self.registry.registerUtility(tdirs, ITranslationDirectories)
for directory in directories:
tdirs = self.registry.queryUtility(ITranslationDirectories)
if tdirs is None:
tdirs = []
self.registry.registerUtility(tdirs,
ITranslationDirectories)

tdirs.insert(0, directory)

self.action(None, register, introspectables=introspectables)
Expand Down

0 comments on commit b24aeb7

Please sign in to comment.