Mercurial > piecrust2
comparison piecrust/sources/autoconfig.py @ 1054:75f1b4460491
sources: Fix ordering and filename confusion in the "ordered" source.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 31 Jan 2018 08:50:39 -0800 |
parents | f8572df0756e |
children | 3d71cd95f90a |
comparison
equal
deleted
inserted
replaced
1053:94d7d5e38571 | 1054:75f1b4460491 |
---|---|
159 if not found: | 159 if not found: |
160 return None | 160 return None |
161 else: | 161 else: |
162 # Find each sub-directory. It can either be a directory with | 162 # Find each sub-directory. It can either be a directory with |
163 # the name itself, or the name with a number prefix. | 163 # the name itself, or the name with a number prefix. |
164 p_pat = r'(\d+_)?' + re.escape(p) | 164 p_pat = r'(\d+_)?' + re.escape(p) + '$' |
165 found = False | 165 found = False |
166 for name in os.listdir(path): | 166 for name in os.listdir(path): |
167 if re.match(p_pat, name): | 167 if re.match(p_pat, name): |
168 path = os.path.join(path, name) | 168 path = os.path.join(path, name) |
169 found = True | 169 found = True |
180 def getSorterIterator(self, it): | 180 def getSorterIterator(self, it): |
181 accessor = self.getSettingAccessor() | 181 accessor = self.getSettingAccessor() |
182 return OrderTrailSortIterator(it, self.setting_name + '_trail', | 182 return OrderTrailSortIterator(it, self.setting_name + '_trail', |
183 value_accessor=accessor) | 183 value_accessor=accessor) |
184 | 184 |
185 def _finalizeContent(self, parent_group, items, groups): | |
186 super()._finalizeContent(parent_group, items, groups) | |
187 | |
188 sn = self.setting_name | |
189 items.sort(key=lambda i: i.metadata['config'][sn]) | |
190 | |
185 def _extractConfigFragment(self, rel_path): | 191 def _extractConfigFragment(self, rel_path): |
186 values = [] | 192 values = [] |
187 for m in self.re_pattern.finditer(rel_path): | 193 for m in self.re_pattern.finditer(rel_path): |
188 val = int(m.group('num')) | 194 val = int(m.group('num')) |
189 values.append(val) | 195 values.append(val) |