diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-09-14 06:49:01 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-09-14 06:49:01 +0000 |
commit | 176fceb15b06598a8bfc32cd3ecc5284212ec739 (patch) | |
tree | f1d8d6c423e9577e25bc81045f9077b5a0ee9990 | |
parent | 836d4220d6d00b71bcf26bfd04a088f70cd71957 (diff) | |
download | portage-176fceb15b06598a8bfc32cd3ecc5284212ec739.tar.gz portage-176fceb15b06598a8bfc32cd3ecc5284212ec739.tar.bz2 portage-176fceb15b06598a8bfc32cd3ecc5284212ec739.zip |
Make isspecific() use the Atom class and fall back to legacy code if the
atom is invalid. Also, optimize called isjustname() legacy code to only
check the last 2 components.
svn path=/main/trunk/; revision=14255
-rw-r--r-- | pym/portage/dep.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/pym/portage/dep.py b/pym/portage/dep.py index 8dbcdd657..38a84dc72 100644 --- a/pym/portage/dep.py +++ b/pym/portage/dep.py @@ -892,7 +892,6 @@ _op = r'([=~]|[><]=?)' _cp = '(' + _cat + '/' + _pkg + '(-' + _version + ')?)' _cpv = '(' + _cp + '-' + _version + ')' -_cpv_re = re.compile('^' + _cpv + '$', re.VERBOSE) _atom_re = re.compile('^(?:' + '(?P<op>' + _op + _cpv + ')|' + '(?P<star>=' + _cpv + r'\*)|' + @@ -945,23 +944,20 @@ def isjustname(mypkg): except InvalidAtom: pass - myparts = mypkg.split('-') - for x in myparts: + for x in mypkg.split('-')[-2:]: if ververify(x): return False return True -iscache = {} - def isspecific(mypkg): """ - Checks to see if a package is in category/package-version or package-version format, - possibly returning a cached result. + Checks to see if a package is in =category/package-version or + package-version format. Example usage: >>> isspecific('media-libs/test') False - >>> isspecific('media-libs/test-3.0') + >>> isspecific('=media-libs/test-3.0') True @param mypkg: The package depstring to check against @@ -972,12 +968,12 @@ def isspecific(mypkg): 2) True if it is """ try: - return iscache[mypkg] - except KeyError: + return mypkg != Atom(mypkg).cp + except InvalidAtom: pass - retval = _cpv_re.match(mypkg) is not None - iscache[mypkg] = retval - return retval + + # Fall back to legacy code for backward compatibility. + return not isjustname(mypkg) def dep_getkey(mydep): """ |