comparison piecrust/sources/base.py @ 871:504ddb370df8

refactor: Fixing some issues with baking assets.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 13 Jun 2017 22:30:27 -0700
parents d9059257743c
children 1d0364614665
comparison
equal deleted inserted replaced
870:48d25fd68b8d 871:504ddb370df8
81 81
82 def __init__(self, app, name, config): 82 def __init__(self, app, name, config):
83 self.app = app 83 self.app = app
84 self.name = name 84 self.name = name
85 self.config = config or {} 85 self.config = config or {}
86 self._cache = None
86 87
87 @property 88 @property
88 def is_theme_source(self): 89 def is_theme_source(self):
89 return self.config['realm'] == REALM_THEME 90 return self.config['realm'] == REALM_THEME
90 91
97 98
98 def getItemMtime(self, item): 99 def getItemMtime(self, item):
99 raise NotImplementedError() 100 raise NotImplementedError()
100 101
101 def getAllContents(self): 102 def getAllContents(self):
103 if self._cache is not None:
104 return self._cache
105
106 cache = []
102 stack = collections.deque() 107 stack = collections.deque()
103 stack.append(None) 108 stack.append(None)
104 while len(stack) > 0: 109 while len(stack) > 0:
105 cur = stack.popleft() 110 cur = stack.popleft()
106 try: 111 try:
110 if contents is not None: 115 if contents is not None:
111 for c in contents: 116 for c in contents:
112 if c.is_group: 117 if c.is_group:
113 stack.append(c) 118 stack.append(c)
114 else: 119 else:
115 yield c 120 cache.append(c)
121 self._cache = cache
122 return cache
116 123
117 def getContents(self, group): 124 def getContents(self, group):
118 raise NotImplementedError("'%s' doesn't implement 'getContents'." % 125 raise NotImplementedError("'%s' doesn't implement 'getContents'." %
119 self.__class__) 126 self.__class__)
120 127