changeset 5781:c12c28282eab

work around page.mtime_usecs() returning 0 for pages without edit-log
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 17 Apr 2011 19:47:04 +0200
parents c1eb3b0a60a2
children c162353f99ed
files MoinMoin/script/maint/mkpagepacks.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/maint/mkpagepacks.py	Sun Apr 17 18:58:38 2011 +0200
+++ b/MoinMoin/script/maint/mkpagepacks.py	Sun Apr 17 19:47:04 2011 +0200
@@ -10,6 +10,7 @@
 
 import os
 import zipfile
+import time
 from datetime import datetime
 
 from MoinMoin.support.python_compatibility import set
@@ -100,6 +101,8 @@
 
         script = [packLine(['MoinMoinPackage', '1']), ]
 
+        fallback_timestamp = int(time.time())
+
         cnt = 0
         for pagename in existing_pages:
             pagename = pagename.strip()
@@ -116,7 +119,11 @@
             zipname = "%d" % cnt
             script.append(packLine([function, zipname, pagename]))
             timestamp = wikiutil.version2timestamp(page.mtime_usecs())
-            zi = zipfile.ZipInfo(filename=zipname, date_time=datetime.fromtimestamp(timestamp).timetuple()[:6])
+            if not timestamp:
+                # page.mtime_usecs() returns 0 for underlay pages
+                timestamp = fallback_timestamp
+            dt = datetime.fromtimestamp(timestamp)
+            zi = zipfile.ZipInfo(filename=zipname, date_time=dt.timetuple()[:6])
             zi.compress_type = COMPRESSION_LEVEL
             zf.writestr(zi, page.get_raw_body().encode("utf-8"))