From 176fceb15b06598a8bfc32cd3ecc5284212ec739 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 14 Sep 2009 06:49:01 +0000 Subject: 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 --- pym/portage/dep.py | 22 +++++++++------------- 1 file 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 + _cpv + ')|' + '(?P=' + _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): """ -- cgit v1.2.3-1-g7c22