e = InvalidData(msg, category='IUSE.missing')
raise InvalidDependString(msg, errors=(e,))
else:
- if _valid_use_re.match(flag) is None:
+ if _get_useflag_re("0" if eapi is None else eapi).match(flag) is None:
raise InvalidDependString(
_("invalid use flag '%s' in conditional '%s'") % (flag, conditional))
return newlist
-_useflag_re = re.compile("^(?P<prefix>[!-]?)(?P<flag>[A-Za-z0-9][A-Za-z0-9+_@-]*)(?P<default>(\(\+\)|\(\-\))?)(?P<suffix>[?=]?)$")
+_usedep_re = {
+ "0": re.compile("^(?P<prefix>[!-]?)(?P<flag>[A-Za-z0-9][A-Za-z0-9+_@-]*)(?P<default>(\(\+\)|\(\-\))?)(?P<suffix>[?=]?)$"),
+# "4": re.compile("^(?P<prefix>[!-]?)(?P<flag>[A-Za-z0-9][A-Za-z0-9+_@.-]*)(?P<default>(\(\+\)|\(\-\))?)(?P<suffix>[?=]?)$"),
+}
+
+def _get_usedep_re(eapi):
+ return _usedep_re["0"]
+# if eapi in ("0", "1", "2_pre1", "2_pre2", "2_pre3", "2", "3_pre1", "3_pre2", "3", "4_pre1"):
+# return _usedep_re["0"]
+# else:
+# return _usedep_re["4"]
class _use_dep(object):
- __slots__ = ("__weakref__", "conditional", "missing_enabled", "missing_disabled",
+ __slots__ = ("__weakref__", "eapi", "conditional", "missing_enabled", "missing_disabled",
"disabled", "enabled", "tokens", "required")
class _conditionals_class(object):
'not_equal': '!%s=',
}
- def __init__(self, use, enabled_flags=None, disabled_flags=None, missing_enabled=None, \
+ def __init__(self, use, eapi, enabled_flags=None, disabled_flags=None, missing_enabled=None, \
missing_disabled=None, conditional=None, required=None):
+ self.eapi = eapi
+
if enabled_flags is not None:
#A shortcut for the classe's own methods.
self.tokens = use
conditional = {}
for x in use:
- m = _useflag_re.match(x)
+ m = _get_usedep_re(self.eapi).match(x)
if m is None:
raise InvalidAtom(_("Invalid use dep: '%s'") % (x,))
tokens = []
for x in self.tokens:
- m = _useflag_re.match(x)
+ m = _get_usedep_re(self.eapi).match(x)
operator = m.group("prefix") + m.group("suffix")
flag = m.group("flag")
else:
tokens.append(x)
- return _use_dep(tokens, enabled_flags=enabled_flags, disabled_flags=disabled_flags, \
+ return _use_dep(tokens, self.eapi, enabled_flags=enabled_flags, disabled_flags=disabled_flags, \
missing_enabled=self.missing_enabled, missing_disabled=self.missing_disabled, required=self.required)
def violated_conditionals(self, other_use, is_valid_flag, parent_use=None):
for x in self.tokens:
- m = _useflag_re.match(x)
+ m = _get_usedep_re(self.eapi).match(x)
operator = m.group("prefix") + m.group("suffix")
flag = m.group("flag")
tokens.append(x)
conditional.setdefault("disabled", set()).add(flag)
- return _use_dep(tokens, enabled_flags=enabled_flags, disabled_flags=disabled_flags, \
+ return _use_dep(tokens, self.eapi, enabled_flags=enabled_flags, disabled_flags=disabled_flags, \
missing_enabled=self.missing_enabled, missing_disabled=self.missing_disabled, \
conditional=conditional, required=self.required)
tokens = []
for x in self.tokens:
- m = _useflag_re.match(x)
+ m = _get_usedep_re(self.eapi).match(x)
operator = m.group("prefix") + m.group("suffix")
flag = m.group("flag")
else:
tokens.append(x)
- return _use_dep(tokens, enabled_flags=enabled_flags, disabled_flags=disabled_flags, \
+ return _use_dep(tokens, self.eapi, enabled_flags=enabled_flags, disabled_flags=disabled_flags, \
missing_enabled=missing_enabled, missing_disabled=missing_disabled, required=self.required)
if sys.hexversion < 0x3000000:
if _use is not None:
use = _use
else:
- use = _use_dep(use_str[1:-1].split(","))
+ use = _use_dep(use_str[1:-1].split(","), "0" if eapi is None else eapi)
without_use = Atom(m.group('without_use'), allow_repo=allow_repo)
else:
use = None
_atom_wildcard_re = re.compile('(?P<simple>(' + _extended_cat + ')/(' + _extended_pkg + '))(:(?P<slot>' + _slot + '))?(' + _repo_separator + '(?P<repo>' + _repo_name + '))?$')
-_valid_use_re = re.compile(r'^[A-Za-z0-9][A-Za-z0-9+_@-]*$')
+_useflag_re = {
+ "0": re.compile(r'^[A-Za-z0-9][A-Za-z0-9+_@-]*$'),
+# "4": re.compile(r'^[A-Za-z0-9][A-Za-z0-9+_@.-]*$'),
+}
+
+def _get_useflag_re(eapi):
+ return _useflag_re["0"]
+# if eapi in ("0", "1", "2_pre1", "2_pre2", "2_pre3", "2", "3_pre1", "3_pre2", "3", "4_pre1"):
+# return _useflag_re["0"]
+# else:
+# return _useflag_re["4"]
def isvalidatom(atom, allow_blockers=False, allow_wildcard=False, allow_repo=False):
"""