diff options
author | Sebastian Luther <SebastianLuther@gmx.de> | 2010-05-21 21:30:41 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-05-21 13:58:07 -0700 |
commit | 9130955e5234cbb7c780be21ce1fe1aea7ac1e7b (patch) | |
tree | 21ce8549de6a2985790d2ce5fe5980a385b9f958 | |
parent | 4bbfb39a2de4ab1659586e268399a06743f6cd16 (diff) | |
download | portage-9130955e5234cbb7c780be21ce1fe1aea7ac1e7b.tar.gz portage-9130955e5234cbb7c780be21ce1fe1aea7ac1e7b.tar.bz2 portage-9130955e5234cbb7c780be21ce1fe1aea7ac1e7b.zip |
Add portage.dep.Atom.violated_conditionals()
-rw-r--r-- | pym/portage/dep/__init__.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index 146caa709..bc04e5be3 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -499,6 +499,26 @@ class _use_dep(object): tokens.extend(x for x in conditional.not_equal if x not in use) return _use_dep(tokens) + + def violated_conditionals(self, use, other_use): + """ + Create a new instance with satisfied conditionals removed. + """ + tokens = [] + + conditional = self.conditional + tokens.extend(x for x in self.enabled if x not in other_use) + tokens.extend("-" + x for x in self.disabled if x in other_use) + if conditional: + tokens.extend(x + "?" for x in conditional.enabled if x in use and not x in other_use) + tokens.extend("!" + x + "?" for x in conditional.disabled if x not in use and x in other_use) + tokens.extend(x + "=" for x in conditional.equal if x in use and x not in other_use) + tokens.extend(x + "=" for x in conditional.equal if x not in use and x in other_use) + tokens.extend("!" + x + "=" for x in conditional.not_equal if x in use and x in other_use) + tokens.extend("!" + x + "=" for x in conditional.not_equal if x not in use and x not in other_use) + + return _use_dep(tokens) + def _eval_qa_conditionals(self, use_mask, use_force): """ @@ -667,6 +687,25 @@ class Atom(_atom_base): atom += str(self.use.evaluate_conditionals(use)) return Atom(atom, self) + def violated_conditionals(self, use, other_use): + """ + Create an atom instance with any USE conditional removed, that is + satisfied by other_use. + @param use: The set of enabled USE flags + @type use: set + @param use: The set of enabled USE flags to check against + @type use: set + @rtype: Atom + @return: an atom instance with any satisfied USE conditionals removed + """ + if not self.use: + return self + atom = remove_slot(self) + if self.slot: + atom += ":%s" % self.slot + atom += str(self.use.violated_conditionals(use, other_use)) + return Atom(atom, self) + def __copy__(self): """Immutable, so returns self.""" return self |