John Mulligan avatar John Mulligan committed 3f50973

cache create and modified times

Comments (0)

Files changed (4)

muyhomepage2/metadata.py

 
 
 def writepagecache(data, fp):
-    for (filename, ccode, title, action) in data:
-        parts = [filename, ccode, title, action]
-        parts = [p or '.' for p in parts]
+    for (filename, ccode, title, action, ctime, mtime) in data:
+        ctime, mtime = int(ctime), int(mtime)
+        parts = [filename, ccode, title, action, ctime, mtime]
+        parts = [str(p or '.') for p in parts]
         parts = [urllib.quote(p) for p in parts]
         fp.write('%s\n' % ' '.join(parts))
 
             return urllib.unquote(value)
     for line in fp:
         parts = line.split()
-        assert len(parts) == 4
-        yield tuple([_unquote(p) for p in parts])
+        assert len(parts) == 6
+        parts = [_unquote(p) for p in parts]
+        parts[4] = int(parts[4])
+        parts[5] = int(parts[5])
+        yield parts
 
 
 def writetagcache(data, fp):

muyhomepage2/page.py

 
 
 class PseduoPage(object):
-    def __init__(self, filename, contentcode, title, action):
+    def __init__(self, filename, contentcode, title, action, ctime, mtime):
         self.filename = filename
         self.contentcode = contentcode
         self.title = title
         self.action = action
+        self._created = util.When(ctime)
+        self._modified = util.When(mtime)
         self.tags = []
         self.headers = {}
+
+    def created(self):
+        return self._created
+
+    def modified(self):
+        return self._modified

muyhomepage2/site.py

 
 
 def write_site_pages(wsite, filename):
-    pdata = ((p.filename, p.contentcode, p.title, p.action)
+    pdata = ((p.filename, p.contentcode, p.title, p.action, 
+                    p.created(), p.modified())
             for p in wsite.pages)
     fp = open(filename, 'w')
     try:
         return pages
     fp = open(filename)
     try:
-        for fn, ccode, title, action in metadata.readpagecache(fp):
-            pages.add(page.PseduoPage(fn, ccode, title, action))
+        for args in metadata.readpagecache(fp):
+            pages.add(page.PseduoPage(*args))
     finally:
         fp.close()
     return pages

muyhomepage2/util.py

     def utc(self):
         return time.gmtime(self._time)
 
+    def __int__(self):
+        return int(self._time)
+
     def __str__(self):
         return time.strftime(TIME_FMT_MUY, self.local())
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.