Skip to content
Permalink
Browse files

Report missing/unknown dates in posts (#2505, #2506)

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Sep 25, 2016
1 parent dda718c commit de83db3d920aeca4fab03ab07c7653f6e962e794
Showing with 8 additions and 1 deletion.
  1. +4 −0 CHANGES.txt
  2. +4 −1 nikola/post.py
@@ -4,6 +4,10 @@ New in master
Bugfixes
--------

* Report missing/unknown dates in posts with filenames
(Issues #2505, #2506)
* Report filename of post that raised exception when scanning
(Issue #2505)
* Accept ``page`` and ``pages`` for the ``type`` field in post lists
* Don’t crash if a post list has no posts (Issue #2489)

@@ -176,7 +176,10 @@ def __init__(
os.stat(self.source_path).st_ctime).replace(tzinfo=dateutil.tz.tzutc()).astimezone(tzinfo)

# If time zone is set, build localized datetime.
self.date = to_datetime(self.meta[self.default_lang]['date'], tzinfo)
try:
self.date = to_datetime(self.meta[self.default_lang]['date'], tzinfo)
except ValueError:
raise OSError("Invalid date '{0}' in file {1}".format(self.meta[self.default_lang]['date'], source_path))

This comment has been minimized.

Copy link
@ralsina

ralsina Sep 25, 2016

Member

why OSError? Maybe ValueError?

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Sep 25, 2016

Author Member

OSError is also used on line 191 for “no title, slug, date”. Should I change both?

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Sep 25, 2016

Author Member

Fixed in a021717.


if 'updated' not in default_metadata:
default_metadata['updated'] = default_metadata.get('date', None)

0 comments on commit de83db3

Please sign in to comment.
You can’t perform that action at this time.