[csw-devel] SF.net SVN: gar:[19739] csw/mgar/gar/v2/lib/python/generate_catalog_file.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Nov 25 10:29:14 CET 2012


Revision: 19739
          http://gar.svn.sourceforge.net/gar/?rev=19739&view=rev
Author:   wahwah
Date:     2012-11-25 09:29:14 +0000 (Sun, 25 Nov 2012)
Log Message:
-----------
generate_catalog_file: Handle an empty catalog.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/generate_catalog_file.py

Modified: csw/mgar/gar/v2/lib/python/generate_catalog_file.py
===================================================================
--- csw/mgar/gar/v2/lib/python/generate_catalog_file.py	2012-11-25 09:27:15 UTC (rev 19738)
+++ csw/mgar/gar/v2/lib/python/generate_catalog_file.py	2012-11-25 09:29:14 UTC (rev 19739)
@@ -81,8 +81,9 @@
     if os.path.exists(out_file):
       raise Error("File %s already exists." % out_file)
     lines = []
-    for pkg_data in self.catalog:
-      lines.append(self.ComposeCatalogLine(pkg_data))
+    if self.catalog:  # the catalog might be None
+      for pkg_data in self.catalog:
+        lines.append(self.ComposeCatalogLine(pkg_data))
     with open(out_file, "w") as fd:
       fd.write("\n".join(lines))
 
@@ -91,9 +92,10 @@
     if os.path.exists(out_file):
       raise Error("File %s already exists." % out_file)
     lines = []
-    for pkg_data in self.catalog:
-      pkg_stats = self.pkgcache.GetPkgstats(pkg_data["md5_sum"])
-      lines.append(pkg_stats["pkginfo"]["NAME"])
+    if self.catalog:
+      for pkg_data in self.catalog:
+        pkg_stats = self.pkgcache.GetPkgstats(pkg_data["md5_sum"])
+        lines.append(pkg_stats["pkginfo"]["NAME"])
     with open(out_file, "w") as fd:
       fd.write("\n".join(lines))
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list