Skip to content

Commit

Permalink
Report missing/unknown dates in posts (#2505, #2506)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Sep 25, 2016
1 parent dda718c commit de83db3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.txt
Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion nikola/post.py
Expand Up @@ -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)
Expand Down

0 comments on commit de83db3

Please sign in to comment.