comparison piecrust/data/pagedata.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 cc2647360036
children
comparison
equal deleted inserted replaced
978:7e51d14097cb 979:45ad976712ec
1 import copy
1 import time 2 import time
2 import logging 3 import logging
3 import collections.abc 4 import collections.abc
4 from piecrust.sources.base import AbortedSourceUseError 5 from piecrust.sources.base import AbortedSourceUseError
5 6
163 def __init__(self, page, ctx): 164 def __init__(self, page, ctx):
164 super().__init__(page) 165 super().__init__(page)
165 self._ctx = ctx 166 self._ctx = ctx
166 167
167 def _load(self): 168 def _load(self):
169 from piecrust.uriutil import split_uri
170
168 page = self._page 171 page = self._page
169 set_val = self._setValue 172 set_val = self._setValue
173
174 page_url = page.getUri(self._ctx.sub_num)
175 _, rel_url = split_uri(page.app, page_url)
170 176
171 dt = page.datetime 177 dt = page.datetime
172 for k, v in page.source_metadata.items(): 178 for k, v in page.source_metadata.items():
173 set_val(k, v) 179 set_val(k, v)
174 set_val('url', page.getUri(self._ctx.sub_num)) 180 set_val('url', page_url)
181 set_val('rel_url', rel_url)
182 set_val('route', copy.deepcopy(page.source_metadata['route_params']))
183
175 set_val('timestamp', time.mktime(dt.timetuple())) 184 set_val('timestamp', time.mktime(dt.timetuple()))
176 set_val('datetime', { 185 set_val('datetime', {
177 'year': dt.year, 'month': dt.month, 'day': dt.day, 186 'year': dt.year, 'month': dt.month, 'day': dt.day,
178 'hour': dt.hour, 'minute': dt.minute, 'second': dt.second}) 187 'hour': dt.hour, 'minute': dt.minute, 'second': dt.second})
179 188