[Python-checkins] python/nondist/sandbox/pep262 TODO, 1.1,
1.2 install_db.py, 1.4, 1.5
akuchling at users.sourceforge.net
akuchling at users.sourceforge.net
Sat Mar 20 12:04:45 EST 2004
Update of /cvsroot/python/python/nondist/sandbox/pep262
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15919
Modified Files:
TODO install_db.py
Log Message:
Allow using a list of paths
Index: TODO
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/pep262/TODO,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TODO 19 Feb 2004 02:58:35 -0000 1.1
--- TODO 20 Mar 2004 17:04:43 -0000 1.2
***************
*** 1,3 ****
--- 1,4 ----
+ * Store multiple databases
* Should the package database store the Conflicts and Obsoletes information?
* Write version requirement parser & evaluator
Index: install_db.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/pep262/install_db.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** install_db.py 20 Mar 2004 16:09:06 -0000 1.4
--- install_db.py 20 Mar 2004 17:04:43 -0000 1.5
***************
*** 18,29 ****
from distutils.dist import DistributionMetadata
- INSTALLDB = ('%s%slib%spython%i.%i%sinstall' % (sys.prefix, os.sep,
- os.sep,
- sys.version_info[0],
- sys.version_info[1],
- os.sep))
- # XXX temporary hack for testing
- INSTALLDB = '/tmp/i'
-
_inst_db = None
def get_install_db ():
--- 18,21 ----
***************
*** 34,57 ****
class InstallationDatabase:
! def __init__ (self, path=None):
"""InstallationDatabase(path:string)
Read the installation database rooted at the specified path.
If path is None, INSTALLDB is used as the default.
"""
! if path is None:
! path = INSTALLDB
! self.path = path
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
--- 26,47 ----
class InstallationDatabase:
! def __init__ (self, paths=None):
"""InstallationDatabase(path:string)
Read the installation database rooted at the specified path.
If path is None, INSTALLDB is used as the default.
"""
! self.paths = paths
self._cache = {}
! def get_distribution (self, dist_name):
! """get_distribution(dist_name:string) : SoftwareDistribution
Get the object corresponding to a single distribution.
"""
try:
! return self._cache[dist_name]
except KeyError:
for distribution in self:
! self._cache[dist_name] = distribution
! if distribution.name == dist_name:
return distribution
***************
*** 86,91 ****
def __init__ (self, instdb):
self.instdb = instdb
! self.queue = [instdb.path]
!
def next (self):
--- 76,83 ----
def __init__ (self, instdb):
self.instdb = instdb
! if instdb.paths is None:
! self.queue = sys.path[:]
! else:
! self.queue = instdb.paths
def next (self):
***************
*** 214,217 ****
--- 206,212 ----
returning a possibly-empty list of mismatches.
"""
+ if not self.has_file(path):
+ return ["File not part of this distribution"]
+
# XXX what to do if the file doesn't exist?
digest = None
***************
*** 273,277 ****
if __name__ == '__main__':
! db = InstallationDatabase('/tmp/i/')
for p in db:
print p.__dict__
--- 268,272 ----
if __name__ == '__main__':
! db = InstallationDatabase(['/tmp/i/'])
for p in db:
print p.__dict__
More information about the Python-checkins
mailing list