[csw-devel] SF.net SVN: gar:[13105] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sat Jan 29 16:47:31 CET 2011
Revision: 13105
http://gar.svn.sourceforge.net/gar/?rev=13105&view=rev
Author: wahwah
Date: 2011-01-29 15:47:31 +0000 (Sat, 29 Jan 2011)
Log Message:
-----------
checkpkg: Support for catalogname-indexed data
OpencswCatalog class can now return a dictionary indexed by
catalognames.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/catalog.py
csw/mgar/gar/v2/lib/python/catalog_test.py
Modified: csw/mgar/gar/v2/lib/python/catalog.py
===================================================================
--- csw/mgar/gar/v2/lib/python/catalog.py 2011-01-29 15:47:01 UTC (rev 13104)
+++ csw/mgar/gar/v2/lib/python/catalog.py 2011-01-29 15:47:31 UTC (rev 13105)
@@ -68,6 +68,7 @@
def __init__(self, fd):
self.fd = fd
self.by_basename = None
+ self.by_catalogname = None
self.catalog_data = None
def _ParseCatalogLine(self, line):
@@ -155,3 +156,15 @@
logging.error("%s is missing the file_basename field", d)
self.by_basename[d["file_basename"]] = d
return self.by_basename
+
+ def GetDataByCatalogname(self):
+ if not self.by_catalogname:
+ self.by_catalogname = {}
+ cd = self.GetCatalogData()
+ for d in cd:
+ if "catalogname" not in d:
+ logging.error("%s is missing the catalogname field", d)
+ if d["catalogname"] in self.by_catalogname:
+ logging.warning("Catalog name %s is duplicated!", d["catalogname"])
+ self.by_catalogname[d["catalogname"]] = d
+ return self.by_catalogname
Modified: csw/mgar/gar/v2/lib/python/catalog_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/catalog_test.py 2011-01-29 15:47:01 UTC (rev 13104)
+++ csw/mgar/gar/v2/lib/python/catalog_test.py 2011-01-29 15:47:31 UTC (rev 13105)
@@ -2,7 +2,25 @@
import unittest
import catalog
+import os.path
+from StringIO import StringIO
+CATALOG_LINE_1 = (
+ "syslog_ng 3.0.4,REV=2009.08.30 "
+ "CSWsyslogng "
+ "syslog_ng-3.0.4,REV=2009.08.30-SunOS5.8-i386-CSW.pkg.gz "
+ "cfe40c06e994f6e8d3b191396d0365cb 137550 "
+ "CSWgcc4corert|CSWeventlog|CSWosslrt|CSWzlib|CSWpcrert|CSWggettextrt|"
+ "CSWglib2|CSWtcpwrap|CSWcswclassutils|CSWcommon none")
+
+CATALOG_LINE_2 = (
+ "syslog_ng 3.0.4,REV=2009.10.12 "
+ "CSWsyslogng "
+ "syslog_ng-3.0.4,REV=2009.10.12-SunOS5.8-i386-CSW.pkg.gz "
+ "a1e9747ac3aa04c0497d2a3a23885995 137367 "
+ "CSWcswclassutils|CSWgcc4corert|CSWeventlog|CSWosslrt|CSWzlib|CSWpcrert|"
+ "CSWggettextrt|CSWglib2|CSWtcpwrap|CSWcswclassutils|CSWcommon none")
+
class OpencswCatalogUnitTest(unittest.TestCase):
def test_ParseCatalogLine_1(self):
@@ -24,6 +42,23 @@
'version': '1.2,REV=2010.05.17'}
self.assertEquals(expected, parsed)
+ def testGetDataByCatalogname(self):
+ expected = {'syslog_ng': {
+ 'category': 'none',
+ 'i_deps': (),
+ 'pkgname': 'CSWsyslogng',
+ 'md5sum': 'cfe40c06e994f6e8d3b191396d0365cb',
+ 'version': '3.0.4,REV=2009.08.30',
+ 'deps': ('CSWgcc4corert', 'CSWeventlog', 'CSWosslrt', 'CSWzlib',
+ 'CSWpcrert', 'CSWggettextrt', 'CSWglib2', 'CSWtcpwrap',
+ 'CSWcswclassutils', 'CSWcommon'),
+ 'file_basename': 'syslog_ng-3.0.4,REV=2009.08.30-SunOS5.8-i386-CSW.pkg.gz',
+ 'size': '137550',
+ 'catalogname': 'syslog_ng'}}
+ fd = StringIO(CATALOG_LINE_1)
+ oc = catalog.OpencswCatalog(fd)
+ self.assertEqual(expected, oc.GetDataByCatalogname())
+
if __name__ == '__main__':
unittest.main()
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