[Python-checkins] python/nondist/sandbox/pep262 install_db.py, 1.3,
1.4
akuchling at users.sourceforge.net
akuchling at users.sourceforge.net
Sat Mar 20 11:09:09 EST 2004
Update of /cvsroot/python/python/nondist/sandbox/pep262
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4997
Modified Files:
install_db.py
Log Message:
Rename Package -> Distribution (SoftwareDistribution for the class name)
Index: install_db.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/pep262/install_db.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** install_db.py 31 Mar 2003 20:08:46 -0000 1.3
--- install_db.py 20 Mar 2004 16:09:06 -0000 1.4
***************
*** 1,5 ****
"""distutils.install_db
! Code for the database of installed Python packages.
"""
--- 1,5 ----
"""distutils.install_db
! Code for the database of installed Python distributions.
"""
***************
*** 44,78 ****
self._cache = {}
! def get_package (self, package_name):
! """get_package(package_name:string) : Package
! Get the object corresponding to a single package.
"""
try:
! return self._cache[package_name]
except KeyError:
! for package in self:
! self._cache[package_name] = package
! if package.name == package_name:
! return package
return None
! def list_packages (self):
! """list_packages() : [Package]
! Return a list of all packages installed on the system,
enumerated in no particular order.
"""
return list(self)
! def find_package (self, path):
! """find_file(path:string) : Package
! Search and return the package containing the file 'path'.
! Returns None if the file doesn't belong to any package
that the InstallationDatabase knows about.
XXX should this work for directories?
"""
! for package in self:
! if package.has_file(path):
! return package
return None
--- 44,78 ----
self._cache = {}
! def get_distribution (self, distribution_name):
! """get_distribution(distribution_name:string) : SoftwareDistribution
! Get the object corresponding to a single distribution.
"""
try:
! return self._cache[distribution_name]
except KeyError:
! for distribution in self:
! self._cache[distribution_name] = distribution
! if distribution.name == distribution_name:
! return distribution
return None
! def list_distributions (self):
! """list_distributions() : [SoftwareDistribution]
! Return a list of all distributions installed on the system,
enumerated in no particular order.
"""
return list(self)
! def find_distribution (self, path):
! """find_file(path:string) : SoftwareDistribution
! Search and return the distribution containing the file 'path'.
! Returns None if the file doesn't belong to any distribution
that the InstallationDatabase knows about.
XXX should this work for directories?
"""
! for distribution in self:
! if distribution.has_file(path):
! return distribution
return None
***************
*** 101,125 ****
break
! return Package(filename)
! class Package(DistributionMetadata):
"""Instance attributes:
name : string
! Name of package
filename : string
! Name of file in which the package's data is stored.
files : {string : (size:int, perms:int, owner:string, group:string,
digest:string)}
! Dictionary mapping the path of a file installed by this package
to information about the file.
requires : [string]
! List of requirements for this package.
provides : [string]
! List of modules provided by this package.
conflicts : [string]
! List of packages that conflict with this package.
obsoletes : [string]
! List of packages that are rendered obsolete by this package.
"""
--- 101,125 ----
break
! return SoftwareDistribution(filename)
! class SoftwareDistribution(DistributionMetadata):
"""Instance attributes:
name : string
! Name of distribution
filename : string
! Name of file in which the distribution's data is stored.
files : {string : (size:int, perms:int, owner:string, group:string,
digest:string)}
! Dictionary mapping the path of a file installed by this distribution
to information about the file.
requires : [string]
! List of requirements for this distribution.
provides : [string]
! List of modules provided by this distribution.
conflicts : [string]
! List of distributions that conflict with this distribution.
obsoletes : [string]
! List of distributions that are rendered obsolete by this distribution.
"""
***************
*** 136,144 ****
def __repr__ (self):
! return '<Package %s: %s>' % (self.name, self.filename)
def set_name (self, name):
"""set_name(name:string)
! Set the package name.
"""
self.name = name
--- 136,144 ----
def __repr__ (self):
! return '<Distribution %s: %s>' % (self.name, self.filename)
def set_name (self, name):
"""set_name(name:string)
! Set the distribution name.
"""
self.name = name
***************
*** 204,208 ****
"""has_file(path:string) : Boolean
Returns true if the specified path belongs to a file in this
! package.
"""
return self.files.has_key(path)
--- 204,208 ----
"""has_file(path:string) : Boolean
Returns true if the specified path belongs to a file in this
! distribution.
"""
return self.files.has_key(path)
***************
*** 214,220 ****
returning a possibly-empty list of mismatches.
"""
! input = open(path, 'rb')
! digest = _hash_file(input)
! input.close()
expected = self.files[path]
stats = os.stat(path)
--- 214,223 ----
returning a possibly-empty list of mismatches.
"""
! # XXX what to do if the file doesn't exist?
! digest = None
! if os.path.exists(path):
! input = open(path, 'rb')
! digest = _hash_file(input)
! input.close()
expected = self.files[path]
stats = os.stat(path)
***************
*** 241,245 ****
output = cStringIO.StringIO()
print >>output, 'PKG-INFO FILES REQUIRES PROVIDES'
! self._write_pkg_info(output)
output.write('\n')
for path, t in self.files.items():
--- 244,248 ----
output = cStringIO.StringIO()
print >>output, 'PKG-INFO FILES REQUIRES PROVIDES'
! ##self._write_pkg_info(output)
output.write('\n')
for path, t in self.files.items():
***************
*** 256,260 ****
return output.getvalue()
! # class Package
def _hash_file (input):
--- 259,263 ----
return output.getvalue()
! # class SoftwareDistribution
def _hash_file (input):
***************
*** 273,277 ****
for p in db:
print p.__dict__
! print db.list_packages()
f = open('/tmp/i2', 'wt')
f.write(p.as_text())
--- 276,280 ----
for p in db:
print p.__dict__
! print db.list_distributions()
f = open('/tmp/i2', 'wt')
f.write(p.as_text())
More information about the Python-checkins
mailing list