comparison piecrust/dataproviders/blog.py @ 979:45ad976712ec

tests: Big push to get the tests to pass again. - Lots of fixes everywhere in the code. - Try to handle debug logging in the multiprocessing worker pool when running in pytest. Not perfect, but usable for now. - Replace all `.md` test files with `.html` since now a auto-format extension always sets the format. - Replace `out` with `outfiles` in most places since now blog archives are added to the bake output and I don't want to add expected outputs for blog archives everywhere.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 29 Oct 2017 22:51:57 -0700
parents 1d0364614665
children 492b66482f12
comparison
equal deleted inserted replaced
978:7e51d14097cb 979:45ad976712ec
54 raise AttributeError("No such taxonomy: %s" % name) 54 raise AttributeError("No such taxonomy: %s" % name)
55 55
56 def __iter__(self): 56 def __iter__(self):
57 self._buildPosts() 57 self._buildPosts()
58 self._buildArchives() 58 self._buildArchives()
59 return ['posts', 'years', 'months'] + list(self._taxonomies.keys()) 59 return ['posts', 'years', 'months'] + list(
60 sorted(self._taxonomies.keys()))
60 61
61 def __len__(self): 62 def __len__(self):
62 self._buildPosts() 63 self._buildPosts()
63 self._buildArchives() 64 self._buildArchives()
64 return 3 + len(self._taxonomies) 65 return 3 + len(self._taxonomies)
109 if posts_this_month is None: 110 if posts_this_month is None:
110 timestamp = time.mktime( 111 timestamp = time.mktime(
111 (post_dt.year, post_dt.month, 1, 112 (post_dt.year, post_dt.month, 1,
112 0, 0, 0, 0, 0, -1)) 113 0, 0, 0, 0, 0, -1))
113 posts_this_month = BlogArchiveEntry( 114 posts_this_month = BlogArchiveEntry(
114 source, page, month, timestamp) 115 source, page, month[0], timestamp)
115 monthly_index[month] = posts_this_month 116 monthly_index[month] = posts_this_month
116 posts_this_month._items.append(post.content_item) 117 posts_this_month._items.append(post.content_item)
117 118
118 for tax in taxonomies: 119 for tax in taxonomies:
119 post_term = post.config.get(tax.setting_name) 120 post_term = post.config.get(tax.setting_name)
142 monthly_index.values(), 143 monthly_index.values(),
143 key=lambda e: e.timestamp, reverse=True)) 144 key=lambda e: e.timestamp, reverse=True))
144 145
145 self._taxonomies = {} 146 self._taxonomies = {}
146 for tax_name, entries in tax_index.items(): 147 for tax_name, entries in tax_index.items():
147 self._taxonomies[tax_name] = list(entries.values()) 148 self._taxonomies[tax_name] = list(
149 sorted(entries.values(), key=lambda i: i.term))
148 150
149 self._onIteration(None) 151 self._onIteration(None)
150 152
151 self._archives_built = True 153 self._archives_built = True
152 154
169 self._page = page 171 self._page = page
170 self._items = [] 172 self._items = []
171 self._iterator = None 173 self._iterator = None
172 174
173 def __str__(self): 175 def __str__(self):
174 return self.name 176 return str(self.name)
175 177
176 def __int__(self): 178 def __int__(self):
177 return int(self.name) 179 return int(self.name)
178 180
179 @property 181 @property