r417 - in branches/rewrite: . src
Otavio Salvador
partial-mirror-devel@lists.alioth.debian.org
Thu, 16 Dec 2004 07:43:37 -0700
Author: otavio
Date: Thu Dec 16 07:43:35 2004
New Revision: 417
Modified:
branches/rewrite/ (props changed)
branches/rewrite/src/PackageList.py
Log:
r1355@nurf: otavio | 2004-12-16T14:43:55.850716Z
- Change _satisfyPackage to allow non-recursive calling;
- Change resolve{Suggests, Recommends} to use the above change;
Modified: branches/rewrite/src/PackageList.py
==============================================================================
--- branches/rewrite/src/PackageList.py (original)
+++ branches/rewrite/src/PackageList.py Thu Dec 16 07:43:35 2004
@@ -164,7 +164,7 @@
self._provides[p].remove(package)
- def _satisfyPackage(self, package, field, pkglist, checkingTree = []):
+ def _satisfyPackage(self, package, field, pkglist, checkingTree = [], recursive=True):
"""
Recursive function used to compute the dependencies of the list of
packages against an external package list.
@@ -184,6 +184,8 @@
- *checkingTree*: list of packages already considered on the
dependency check, to avoid loops.
+
+ - *recursive*: turn it false to don't include recursively.
"""
if package.has_key(field):
# Handle ciclical depends
@@ -200,10 +202,16 @@
# We have it on full list
# TODO: Add version cheking
if pkgname in pkglist and pkgname not in self:
- if self._satisfyPackage(pkglist[pkgname], field, pkglist, checkingTree):
- if pkgname not in self:
- self.add(pkglist[pkgname])
- break
+ if recursive:
+ if self._satisfyPackage(pkglist[pkgname], field, pkglist, checkingTree):
+ # Since it is called recursively we
+ # need to check if was not already
+ # included.
+ if pkgname not in self:
+ self.add(pkglist[pkgname])
+ else:
+ self.add(pkglist[pkgname])
+ break
# When a package is not found, we should look
# if it's not a virtual package
@@ -211,16 +219,22 @@
if pkglist._provides.has_key(pkgname):
for virtual_pkg in pkglist._provides[pkgname]:
if virtual_pkg['Package'] in self:
- print " Found %s." % virtual_pkg['Package']
found = True
break
else:
- virtual_pkg = pkglist._provides[pkgname][0]
- if self._satisfyPackage(virtual_pkg, field, pkglist, checkingTree):
- if virtual_pkg['Package'] not in self:
- self.add(virtual_pkg)
- found = True
- break
+ virtual_pkg = pkglist._provides[pkgname][0]
+ if recursive:
+ if pkgname not in self:
+ if self._satisfyPackage(virtual_pkg, field, pkglist, checkingTree):
+ # Since it is called
+ # recursively we need to check
+ # if was not already included.
+ if virtual_pkg['Package'] not in self:
+ self.add(virtual_pkg)
+ else:
+ self.add(virtual_pkg)
+ found = True
+ break
if found: break
else:
print pkgname, "unavailable. Your mirror could be broken seriously."
@@ -240,29 +254,27 @@
for field in ('Depends', 'Pre-Depends'):
self._satisfyPackage(p, field, pkglist)
- def resolveRecommends(self, pkglist):
+ def resolveRecommends(self, pkglist, recursive=True):
"""
Add all the recommended packages and the dependencies to our list taking
missing ones from `pkglist`.
- Note that the current implementation adds all recommended packages recursively
- (that is, the Recommends of recommended packages are also included).
+ To don't add it recursively, call it passing recursive as False.
"""
for p in self.values():
for field in ('Recommends', 'Depends', 'Pre-Depends'):
- self._satisfyPackage(p, field, pkglist)
+ self._satisfyPackage(p, field, pkglist, recursive)
- def resolveSuggests(self, pkglist):
+ def resolveSuggests(self, pkglist, recursive=True):
"""
Add all the suggested packages and the dependencies to our list taking
missing ones from `pkglist`.
- Note that the current implementation adds all Suggestions recursively
- (that is, the Suggestions of suggested packages are also included).
+ To don't add it recursively, call it passing recursive as False.
"""
for p in self.values():
for field in ('Suggests', 'Depends', 'Pre-Depends'):
- self._satisfyPackage(p, field, pkglist)
+ self._satisfyPackage(p, field, pkglist, recursive)
def filter(self, condition):
"""