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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Wed Dec 15 09:45:27 CET 2010


Revision: 11952
          http://gar.svn.sourceforge.net/gar/?rev=11952&view=rev
Author:   wahwah
Date:     2010-12-15 08:45:27 +0000 (Wed, 15 Dec 2010)

Log Message:
-----------
checkpkg: Cope with dashes in catalognames

If there are dashes in catalognames, don't misalign all fields.  If the number
of fields in a package name exceeds 6, assume all extra fields belong to the
catalog name.

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

Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py	2010-12-15 04:27:05 UTC (rev 11951)
+++ csw/mgar/gar/v2/lib/python/opencsw.py	2010-12-15 08:45:27 UTC (rev 11952)
@@ -76,7 +76,11 @@
   if p.endswith(".pkg"):
     p = p[:-4]
   bits = p.split("-")
-  catalogname = bits[0]
+  if len(bits) >= 6:
+    catalogname = "-".join(bits[:len(bits) - 4])
+    bits = [catalogname] + bits[len(bits) - 4:]
+  else:
+    catalogname = bits[0]
   if len(bits) < 2:
     version, version_info, revision_info = None, None, None
     full_version_string = None

Modified: csw/mgar/gar/v2/lib/python/opencsw_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw_test.py	2010-12-15 04:27:05 UTC (rev 11951)
+++ csw/mgar/gar/v2/lib/python/opencsw_test.py	2010-12-15 08:45:27 UTC (rev 11952)
@@ -132,6 +132,13 @@
     self.assertEqual(parsed["osrel"], "unspecified")
     self.assertEqual(parsed["catalogname"], "RICHPse")
 
+  def testParsePackageFileName_OneDashTooMany(self):
+    file_name = ("boost-jam-3.1.18,REV=2010.12.15-"
+                 "SunOS5.9-sparc-UNCOMMITTED.pkg.gz")
+    parsed = opencsw.ParsePackageFileName(file_name)
+    self.assertEqual(parsed["arch"], "sparc")
+    self.assertEqual(parsed["catalogname"], "boost-jam")
+
   def testParsePackageFileName_Nonsense(self):
     """Checks if the function can sustain a non-conformant string."""
     file_name = "What if I wrote a letter to my grandma here?"


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