aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-03-22 00:00:15 +0100
committerGravatar Tom Willemsen2012-03-22 00:00:15 +0100
commitf30c00af6db5e5a4eab516058829d46c2d379000 (patch)
tree1cb33f7ccf2eb65221f8eca25ec5ff5414c4db59
parenteb05d87e117a59ef82b0172783af0c2a60c54c9f (diff)
downloadryuslash.org-f30c00af6db5e5a4eab516058829d46c2d379000.tar.gz
ryuslash.org-f30c00af6db5e5a4eab516058829d46c2d379000.zip
Fallback to published or now
When trying to set the `updated' property of a `Post', when no `updated_parsed' is available, try `published_parsed' or use `datetime.now()' if that is also not available.
-rw-r--r--aggregator/management/commands/loadfeeds.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/aggregator/management/commands/loadfeeds.py b/aggregator/management/commands/loadfeeds.py
index 04316b3..bedf65d 100644
--- a/aggregator/management/commands/loadfeeds.py
+++ b/aggregator/management/commands/loadfeeds.py
@@ -20,14 +20,12 @@ class Command(BaseCommand):
for entry in parsed.entries:
if not Post.objects.filter(post_id=entry.id).exists():
+ dt = entry.updated_parsed \
+ or entry.published_parsed \
+ or datetime.datetime.now()
updated = datetime.datetime(
- entry.updated_parsed.tm_year,
- entry.updated_parsed.tm_mon,
- entry.updated_parsed.tm_mday,
- entry.updated_parsed.tm_hour,
- entry.updated_parsed.tm_min,
- entry.updated_parsed.tm_sec)
-
+ dt.tm_year, dt.tm_mon, dt.tm_mday,
+ dt.tm_hour, dt.tm_min, dt.tm_sec)
post = Post(post_id=entry.id,
title=entry.title,
remote_url=entry.link,