aboutsummaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorJason Stubbs <jstubbs@gentoo.org>2005-05-03 13:49:35 +0000
committerJason Stubbs <jstubbs@gentoo.org>2005-05-03 13:49:35 +0000
commit0e4679618386a565d6827d43aad5ad66bc31e970 (patch)
treea2505cb2f01e87721f26a76154ee91fa6978ef4d /pym
parentAdded methods for modifying DependSpec externally. (diff)
downloadportage-cvs-0e4679618386a565d6827d43aad5ad66bc31e970.tar.gz
portage-cvs-0e4679618386a565d6827d43aad5ad66bc31e970.tar.bz2
portage-cvs-0e4679618386a565d6827d43aad5ad66bc31e970.zip
Fixed some bugs in the new intersects() and encapsulates() methods. Created
a transform_dependspec() function that reorders DependSpec elements based on supplied preferences.
Diffstat (limited to 'pym')
-rw-r--r--pym/portage_dep.py47
-rw-r--r--pym/portage_syntax.py16
2 files changed, 53 insertions, 10 deletions
diff --git a/pym/portage_dep.py b/pym/portage_dep.py
index 1fedb40..4b0e2cc 100644
--- a/pym/portage_dep.py
+++ b/pym/portage_dep.py
@@ -1,8 +1,8 @@
# deps.py -- Portage dependency resolution functions
# Copyright 2003-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage_dep.py,v 1.29 2005/05/03 10:20:01 jstubbs Exp $
-cvs_id_string="$Id: portage_dep.py,v 1.29 2005/05/03 10:20:01 jstubbs Exp $"[5:-2]
+# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage_dep.py,v 1.30 2005/05/03 13:49:35 jstubbs Exp $
+cvs_id_string="$Id: portage_dep.py,v 1.30 2005/05/03 13:49:35 jstubbs Exp $"[5:-2]
# DEPEND SYNTAX:
#
@@ -669,6 +669,49 @@ class GluePkg(portage_syntax.CPV):
self.rdeps = portage_syntax.DependSpec(rdeps).resolve_conditions(self.use)
+def transform_dependspec(dependspec, preferences):
+ def dotransform(dependspec, preferences):
+ dependspec = copy.copy(dependspec)
+ elements = dependspec.elements
+ dependspec.elements = []
+ neworder = []
+ prio = len(preferences)+1
+ idx = -1
+ for element in elements[:]:
+ if isinstance(element, portage_syntax.DependSpec):
+ neworder.append(dotransform(element, preferences))
+ elements.remove(element)
+ for pref in preferences:
+ idx += 1
+ for element in elements[:]:
+ if pref.intersects(element):
+ if idx < prio:
+ prio = idx
+ if pref.encapsulates(element):
+ neworder.append((idx, element))
+ elements.remove(element)
+ else:
+ subdependspec = portage_syntax.DependSpec(element_class=portage_syntax.Atom)
+ if element.encapsulates(pref):
+ subsubdependspec = portage_syntax.DependSpec(element_class=portage_syntax.Atom)
+ subsubdependspec.add_element(pref)
+ subsubdependspec.add_element(element)
+ subdependspec.add_element(subsubdependspec)
+ else:
+ subdependspec.add_element(pref)
+ subdependspec.add_element(element)
+ subdependspec.preferential = True
+ neworder.append((idx, subdependspec))
+ elements.remove(element)
+ neworder.sort()
+ for element in neworder:
+ dependspec.add_element(element[1])
+ for element in elements:
+ dependspec.add_element(element)
+ return (prio, dependspec)
+ return dotransform(dependspec, preferences)[1]
+
+
class TargetGraph(object):
def __init__(self):
diff --git a/pym/portage_syntax.py b/pym/portage_syntax.py
index f18ccb3..a6bb27b 100644
--- a/pym/portage_syntax.py
+++ b/pym/portage_syntax.py
@@ -325,19 +325,19 @@ class Atom(object):
return False
def intersects(self, atom):
- if self == other:
+ if self == atom:
return True
- if self.key != atom.key:
+ if self.cpv.key != atom.cpv.key:
return False
- if self.blocks != other.blocks:
+ if self.blocks != atom.blocks:
return False
- if not self.operator or not other.operator:
+ if not self.operator or not atom.operator:
return True
if self.cpv == other.cpv:
- if self.operator == other.operator:
+ if self.operator == atom.operator:
return True
if self.operator == "<":
- return (other.operator[0] == "<")
+ return (atom.operator[0] == "<")
if self.operator == ">":
return (other.operator[0] == ">" or other.operator == "~")
if self.operator == "=":
@@ -369,12 +369,12 @@ class Atom(object):
if not self.intersects(atom):
return False
- if self.operator and not other.operator:
+ if self.operator and not atom.operator:
return False
if not self.operator:
return True
- if self.cpv == other.cpv:
+ if self.cpv == atom.cpv:
if self.operator == other.operator:
return True
if other.operator == "=":