[csw-devel] SF.net SVN: gar:[13103] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sat Jan 29 16:46:28 CET 2011
Revision: 13103
http://gar.svn.sourceforge.net/gar/?rev=13103&view=rev
Author: wahwah
Date: 2011-01-29 15:46:28 +0000 (Sat, 29 Jan 2011)
Log Message:
-----------
checkpkg: OpencswCatalog class gets a file desc
When instantiating OpencswCatalog, it's better to use a file descriptor
than a file name.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/catalog.py
csw/mgar/gar/v2/lib/python/package_stats.py
csw/mgar/gar/v2/lib/python/pkgdb.py
Modified: csw/mgar/gar/v2/lib/python/catalog.py
===================================================================
--- csw/mgar/gar/v2/lib/python/catalog.py 2011-01-29 15:45:54 UTC (rev 13102)
+++ csw/mgar/gar/v2/lib/python/catalog.py 2011-01-29 15:46:28 UTC (rev 13103)
@@ -65,8 +65,8 @@
class OpencswCatalog(object):
"""Represents a catalog file."""
- def __init__(self, file_name):
- self.file_name = file_name
+ def __init__(self, fd):
+ self.fd = fd
self.by_basename = None
self.catalog_data = None
@@ -133,8 +133,7 @@
def GetCatalogData(self):
if not self.catalog_data:
- fd = open(self.file_name, "r")
- self.catalog_data = self._GetCatalogData(fd)
+ self.catalog_data = self._GetCatalogData(self.fd)
return self.catalog_data
def GetDataByBasename(self):
Modified: csw/mgar/gar/v2/lib/python/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py 2011-01-29 15:45:54 UTC (rev 13102)
+++ csw/mgar/gar/v2/lib/python/package_stats.py 2011-01-29 15:46:28 UTC (rev 13103)
@@ -440,7 +440,7 @@
def StatsListFromCatalog(file_name_list, catalog_file_name=None, debug=False):
packages = [inspective_package.InspectiveCswSrv4File(x, debug) for x in file_name_list]
if catalog_file_name:
- catalog_obj = catalog.OpencswCatalog(catalog_file_name)
+ catalog_obj = catalog.OpencswCatalog(open(catalog_file_name, "rb"))
md5s_by_basename = catalog_obj.GetDataByBasename()
for pkg in packages:
basename = os.path.basename(pkg.pkg_path)
Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py 2011-01-29 15:45:54 UTC (rev 13102)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py 2011-01-29 15:46:28 UTC (rev 13103)
@@ -195,7 +195,7 @@
# - read in the catalog file, and build a md5-filename correspondence
# data structure.
logging.debug("Reading the catalog file from disk.")
- src_catalog = catalog.OpencswCatalog(catalog_file)
+ src_catalog = catalog.OpencswCatalog(open(catalog_file, "rb"))
catalog_data = src_catalog.GetCatalogData()
cat_entry_by_md5 = {}
cat_entry_by_basename = {}
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