[csw-devel] SF.net SVN: gar:[12084] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Dec 27 11:17:20 CET 2010
Revision: 12084
http://gar.svn.sourceforge.net/gar/?rev=12084&view=rev
Author: wahwah
Date: 2010-12-27 10:17:20 +0000 (Mon, 27 Dec 2010)
Log Message:
-----------
pkgdb: Handling files with full paths as ids
When given a full path to a package (/foo/bar/baz.pkg), strip off the file
path, because otherwise it can't find packages if you give it the full path.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/pkgdb.py
csw/mgar/gar/v2/lib/python/pkgdb_test.py
Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py 2010-12-27 10:16:47 UTC (rev 12083)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py 2010-12-27 10:17:20 UTC (rev 12084)
@@ -82,9 +82,14 @@
class HtmlGenerator(object):
- def __init__(self, md5_sums, template=None):
- self.md5_sums = md5_sums
+ def __init__(self, identifiers, template=None):
+ """Initialize the object
+
+ args: identifiers: md5 sums or file names of packages
+ template: Optional HTML template
+ """
self.template = template
+ self.identifiers = identifiers
def GetErrorTagsResult(self, srv4):
res = m.CheckpkgErrorTag.select(
@@ -99,8 +104,8 @@
def GenerateHtml(self):
pkgstats = []
# Add error tags
- for md5_sum in self.md5_sums:
- srv4 = GetPkg(md5_sum)
+ for identifier in self.identifiers:
+ srv4 = GetPkg(identifier)
data = cPickle.loads(str(srv4.data_obj.pickle))
if "OPENCSW_REPOSITORY" in data["pkginfo"]:
build_src = data["pkginfo"]["OPENCSW_REPOSITORY"]
@@ -133,7 +138,15 @@
return unicode(t)
+def NormalizeId(some_id):
+ """Used to normalize identifiers (md5, filename).
+
+ Currently, strips paths off given package paths."""
+ return os.path.basename(some_id)
+
+
def GetPkg(some_id):
+ some_id = NormalizeId(some_id)
logging.debug("Selecting from db: %s", repr(some_id))
res = m.Srv4FileStats.select(
sqlobject.OR(
Modified: csw/mgar/gar/v2/lib/python/pkgdb_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb_test.py 2010-12-27 10:16:47 UTC (rev 12083)
+++ csw/mgar/gar/v2/lib/python/pkgdb_test.py 2010-12-27 10:17:20 UTC (rev 12084)
@@ -12,5 +12,11 @@
ci.ComposeCatalogFilePath("/home/mirror/opencsw/current", "SunOS5.9", "sparc"))
+class FunctionUnitTest(unittest.TestCase):
+
+ def testNormalizeIdentifier(self):
+ self.assertEqual("baz", pkgdb.NormalizeId("/foo/bar/baz"))
+
+
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