Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Getting date-related key error #11

Closed
robatron opened this issue May 8, 2011 · 3 comments
Closed

Getting date-related key error #11

robatron opened this issue May 8, 2011 · 3 comments
Labels

Comments

@robatron
Copy link
Contributor

robatron commented May 8, 2011

Regardless of if I include the 'date', 'datetime', or 'time' field or not, I'm getting the following key error:

Traceback (most recent call last):
  File "../wok/wok/wok.py", line 82, in <module>
    Wok()
  File "../wok/wok/wok.py", line 24, in __init__
    self.load_pages()
  File "../wok/wok/wok.py", line 61, in load_pages
    self.all_pages.append(Page(os.path.join(root,f), self.options, renderer))
  File "/home/rob/wok/wok/page.py", line 80, in __init__
    self.build_meta()
  File "/home/rob/wok/wok/page.py", line 143, in build_meta
    self.meta['datetime'] = isodate.parse_datetime(self.meta[datetime_name])
KeyError: 'date'
@robatron
Copy link
Contributor Author

robatron commented May 8, 2011

I think this should fix it:

From dbcf0821bc227e135b546c0cd47d95cee7825c43 Mon Sep 17 00:00:00 2001
From: Rob McGuire-Dale <rob.mcguiredale+git@gmail.com>
Date: Sat, 7 May 2011 18:44:50 -0700
Subject: [PATCH] isodate now parses date immediately out of the metadata (if it exists).

---
 wok/page.py |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/wok/page.py b/wok/page.py
index 2bfd599..19bb017 100644
--- a/wok/page.py
+++ b/wok/page.py
@@ -130,21 +130,11 @@ class Page(object):
         datetime_name=None
         for name in ['time', 'date', 'datetime']:
             if name in self.meta:
-                self.meta['datetime'] = self.meta[name]
+                self.meta['datetime'] = isodate.parse_datetime(self.meta[name])
         else:
             self.meta['datetime'] = datetime.now()
         # Guarantee: datetime exists

-        datetime_name=None
-        for name in ['time', 'date', 'datetime']:
-            if name in self.meta:
-                datetime_name = 'date'
-        if datetime_name:
-            self.meta['datetime'] = isodate.parse_datetime(self.meta[datetime_name])
-        else:
-            self.meta['datetime'] = datetime.now()
-        # Gurantee: datetime exists
-
     def render(self):
         """
         Renders the page to full html.
-- 
1.7.4.1

@mythmon
Copy link
Owner

mythmon commented May 8, 2011

Ok, that is strange. The code you submitted is very similar to what it is supposed to be. Apparently git did not pick up that particular change.

@mythmon
Copy link
Owner

mythmon commented May 8, 2011

In git HEAD this is fixed, as of v0.2. Though the web interface of github is not showing the change.

@mythmon mythmon closed this as completed May 8, 2011
robatron pushed a commit to robatron/wok that referenced this issue May 8, 2011
…sts in the header, removing redundant datetime logic (older version of datetime logic?)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants