useflag/dep_re: less strict if eapi None
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Jun 2011 18:48:19 +0000 (11:48 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Jun 2011 18:48:19 +0000 (11:48 -0700)
When eapi is None then validation is not as strict, since we want the
same to work for multiple EAPIs that may have slightly different rules.

pym/portage/dep/__init__.py
pym/portage/tests/dep/test_use_reduce.py

index ba373241f33d9ebeecd0acb6a82c718e92caab47..b9020a7a76fac9c8d33e60ff43330f35aab7b127 100644 (file)
@@ -641,13 +641,15 @@ _usedep_re = {
 
 def _get_usedep_re(eapi):
        """
+       When eapi is None then validation is not as strict, since we want the
+       same to work for multiple EAPIs that may have slightly different rules.
        @param eapi: The EAPI
        @type eapi: String or None
        @rtype: regular expression object
-       @return: A regular expression object that matches valid USE flags for the
-               given eapi. If eapi is None then the latest supported EAPI is assumed.
+       @return: A regular expression object that matches valid USE deps for the
+               given eapi.
        """
-       if eapi in ("4-python",):
+       if eapi in (None, "4-python",):
                return _usedep_re["4-python"]
        else:
                return _usedep_re["0"]
@@ -1625,7 +1627,16 @@ _useflag_re = {
 }
 
 def _get_useflag_re(eapi):
-       if eapi in ("4-python",):
+       """
+       When eapi is None then validation is not as strict, since we want the
+       same to work for multiple EAPIs that may have slightly different rules.
+       @param eapi: The EAPI
+       @type eapi: String or None
+       @rtype: regular expression object
+       @return: A regular expression object that matches valid USE flags for the
+               given eapi.
+       """
+       if eapi in (None, "4-python",):
                return _useflag_re["4-python"]
        else:
                return _useflag_re["0"]
index ac815632a7e7ba8a839c51b1841dda24ca9c6475..1618430c5d29056cfcb1e084cb6f1a908ac2315f 100644 (file)
@@ -8,7 +8,7 @@ from portage.dep import Atom, use_reduce
 class UseReduceTestCase(object):
        def __init__(self, deparray, uselist=[], masklist=[], \
                matchall=0, excludeall=[], is_src_uri=False, \
-               eapi=None, opconvert=False, flat=False, expected_result=None, \
+               eapi="0", opconvert=False, flat=False, expected_result=None, \
                        is_valid_flag=None, token_class=None):
                self.deparray = deparray
                self.uselist = uselist