From: Zac Medico Date: Mon, 11 Jun 2012 01:15:07 +0000 (-0700) Subject: Add a _get_slot_re() function. X-Git-Tag: v2.2.0_alpha111~58 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c864dd8d26ecc2144fd7e0ae56d12519f94dbd99;p=portage.git Add a _get_slot_re() function. --- diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 75021b9f5..91d7606b2 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -8,7 +8,7 @@ from portage import _encodings, _unicode_decode, _unicode_encode from portage.cache.mappings import slot_dict_class from portage.const import EBUILD_PHASES from portage.dep import Atom, check_required_use, use_reduce, \ - paren_enclose, _slot_re, _slot_separator, _repo_separator + paren_enclose, _get_slot_re, _slot_separator, _repo_separator from portage.versions import _pkg_str, _unknown_repo from portage.eapi import _get_eapi_attrs from portage.exception import InvalidDependString @@ -51,7 +51,7 @@ class Package(Task): self.metadata['CHOST'] = self.root_config.settings.get('CHOST', '') eapi_attrs = _get_eapi_attrs(self.metadata["EAPI"]) slot = self.slot - if _slot_re.match(slot) is None: + if _get_slot_re(eapi_attrs).match(slot) is None: self._invalid_metadata('SLOT.invalid', "SLOT: invalid value: '%s'" % slot) # Avoid an InvalidAtom exception when creating slot_atom. diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 517c873ab..fbbf49dcf 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -12,7 +12,8 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.dbapi.dep_expand:dep_expand', 'portage.dbapi._MergeProcess:MergeProcess', 'portage.dep:dep_getkey,isjustname,match_from_list,' + \ - 'use_reduce,_slot_re', + 'use_reduce,_get_slot_re', + 'portage.eapi:_get_eapi_attrs', 'portage.elog:collect_ebuild_messages,collect_messages,' + \ 'elog_process,_merge_logentries', 'portage.locks:lockdir,unlockdir,lockfile,unlockfile', @@ -687,7 +688,8 @@ class vardbapi(dbapi): (mydir_mtime, cache_data) self._aux_cache["modified"].add(mycpv) - if _slot_re.match(mydata['SLOT']) is None: + eapi_attrs = _get_eapi_attrs(mydata['EAPI']) + if _get_slot_re(eapi_attrs).match(mydata['SLOT']) is None: # Empty or invalid slot triggers InvalidAtom exceptions when # generating slot atoms for packages, so translate it to '0' here. mydata['SLOT'] = _unicode_decode('0') diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index d2df0425d..e6056b104 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -55,6 +55,9 @@ _repo = r'(?:' + _repo_separator + '(' + _repo_name + ')' + ')?' _extended_cat = r'[\w+*][\w+.*-]*' +def _get_slot_re(eapi_attrs): + return _slot_re + _atom_re_cache = {} def _get_atom_re(eapi_attrs):