changeset 4760:14be105b1c32

system/help pages: do not create empty page packages
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 18 Jul 2009 23:31:48 +0200
parents f59207d04c15
children 83390406fc5c
files MoinMoin/script/maint/mkpagepacks.py
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/maint/mkpagepacks.py	Sat Jul 18 23:01:24 2009 +0200
+++ b/MoinMoin/script/maint/mkpagepacks.py	Sat Jul 18 23:31:48 2009 +0200
@@ -87,25 +87,25 @@
             os.remove(filename)
         except OSError:
             pass
+
+        existing_pages = [pagename for pagename in pagelist if Page(request, pagename).exists()]
+        if not existing_pages:
+            return
+
         zf = zipfile.ZipFile(filename, "w", COMPRESSION_LEVEL)
 
+        script = [packLine(['MoinMoinPackage', '1']), ]
+
         cnt = 0
-        script = [packLine(['MoinMoinPackage', '1']), ]
-
-        for pagename in pagelist:
+        for pagename in existing_pages:
             pagename = pagename.strip()
             page = Page(request, pagename)
-            if page.exists():
-                cnt += 1
-                script.append(packLine([function, str(cnt), pagename]))
-                timestamp = wikiutil.version2timestamp(page.mtime_usecs())
-                zi = zipfile.ZipInfo(filename=str(cnt), date_time=datetime.fromtimestamp(timestamp).timetuple()[:6])
-                zi.compress_type = COMPRESSION_LEVEL
-                zf.writestr(zi, page.get_raw_body().encode("utf-8"))
-            else:
-                #import sys
-                #print >>sys.stderr, "Could not find the page %s." % pagename.encode("utf-8")
-                pass
+            cnt += 1
+            script.append(packLine([function, str(cnt), pagename]))
+            timestamp = wikiutil.version2timestamp(page.mtime_usecs())
+            zi = zipfile.ZipInfo(filename=str(cnt), date_time=datetime.fromtimestamp(timestamp).timetuple()[:6])
+            zi.compress_type = COMPRESSION_LEVEL
+            zf.writestr(zi, page.get_raw_body().encode("utf-8"))
 
         script += [packLine(['Print', 'Installed MoinMaster page bundle %s.' % os.path.basename(filename)])]