Mercurial > piecrust2
diff piecrust/page.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 | 84d8fadf9e67 |
children | 1857dbd4580f |
line wrap: on
line diff
--- a/piecrust/page.py Sun Oct 29 22:46:41 2017 -0700 +++ b/piecrust/page.py Sun Oct 29 22:51:57 2017 -0700 @@ -3,7 +3,6 @@ import hashlib import logging import datetime -import dateutil.parser import collections from werkzeug.utils import cached_property from piecrust.configuration import ( @@ -176,6 +175,7 @@ return None if isinstance(page_date, str): + import dateutil.parser try: parsed_d = dateutil.parser.parse(page_date) except Exception as ex: @@ -197,6 +197,7 @@ return page_time if isinstance(page_time, str): + import dateutil.parser try: parsed_t = dateutil.parser.parse(page_time) except Exception as ex: @@ -306,7 +307,7 @@ line_count = 1 while True: nex = txt.find('\n', cur) - if nex < 0: + if nex < 0 or (end >= 0 and nex >= end): break cur = nex + 1 @@ -374,7 +375,7 @@ # Handle text past the last match. lastm = matches[-1] - last_seg_start = lastm.end() + last_seg_start = lastm.end() + 1 seg = ContentSegment( raw[last_seg_start:],