For digestgen(), add a matchnone parameter to use_reduce() that is the
authorZac Medico <zmedico@gentoo.org>
Sat, 11 Sep 2010 19:45:20 +0000 (12:45 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 11 Sep 2010 19:45:20 +0000 (12:45 -0700)
opposite of matchall.

pym/portage/dep/__init__.py

index 7475d85920d5edb0679f1c4ff93a0af204841a69..b1d08e2675db78711ca7b01b7433c2e40ad9b473 100644 (file)
@@ -254,7 +254,7 @@ def paren_enclose(mylist):
        return " ".join(mystrparts)
 
 def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], is_src_uri=False, \
-       eapi=None, opconvert=False, flat=False, is_valid_flag=None, token_class=None):
+       eapi=None, opconvert=False, flat=False, is_valid_flag=None, token_class=None, matchnone=False):
        """
        Takes a dep string and reduces the use? conditionals out, leaving an array
        with subarrays. All redundant brackets are removed.
@@ -281,6 +281,8 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
        @type is_valid_flag: Function
        @param token_class: Convert all non operator tokens into this class
        @type token_class: Class
+       @param matchnone: Treat all conditionals as inactive. Used by digestgen(). 
+       @type matchnone: Bool
        @rtype: List
        @return: The use reduced depend array
        """
@@ -294,6 +296,9 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
        if opconvert and flat:
                raise ValueError("portage.dep.use_reduce: 'opconvert' and 'flat' are mutually exclusive")
 
+       if matchall and matchnone:
+               raise ValueError("portage.dep.use_reduce: 'matchall' and 'matchnone' are mutually exclusive")
+
        def is_active(conditional):
                """
                Decides if a given use conditional is active.
@@ -326,6 +331,9 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
                if matchall:
                        return True
 
+               if matchnone:
+                       return False
+
                return (flag in uselist and not is_negated) or \
                        (flag not in uselist and is_negated)