summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-08 08:10:10 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-08 08:10:10 +0000
commitb675892c7f75112fb845a8e24bd5be0148b85406 (patch)
tree9da1a6bb661374fbabc9db317566598f2947b8bd
parent817594390e64888da26950477ca99bc334eeeed4 (diff)
downloadportage-b675892c7f75112fb845a8e24bd5be0148b85406.tar.gz
portage-b675892c7f75112fb845a8e24bd5be0148b85406.tar.bz2
portage-b675892c7f75112fb845a8e24bd5be0148b85406.zip
Reimplement isspecific() using a single regular expression match. Thanks to
Marat Radchenko <marat@slonopotamus.org> for this patch. svn path=/main/trunk/; revision=14217
-rw-r--r--pym/portage/dep.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index 81364f344..8c3317e67 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -853,6 +853,7 @@ _op = r'([=><~]|([><]=))'
_cp = _cat + '/' + _pkg
_cpv = _cp + '-' + _version
+_cpv_re = re.compile('^' + _cpv + '$')
_atom_re = re.compile(r'^(' +
'(' + _op + _cpv + _slot + _use + ')|' +
'(=' + _cpv + r'\*' + _slot + _use + ')|' +
@@ -932,27 +933,24 @@ def isspecific(mypkg):
Example usage:
>>> isspecific('media-libs/test')
- 0
+ False
>>> isspecific('media-libs/test-3.0')
- 1
+ True
@param mypkg: The package depstring to check against
@type mypkg: String
- @rtype: Integer
+ @rtype: Boolean
@return: One of the following:
- 1) 0 if the package string is not specific
- 2) 1 if it is
+ 1) False if the package string is not specific
+ 2) True if it is
"""
try:
return iscache[mypkg]
except KeyError:
pass
- mysplit = mypkg.split("/")
- if not isjustname(mysplit[-1]):
- iscache[mypkg] = 1
- return 1
- iscache[mypkg] = 0
- return 0
+ retval = _cpv_re.match(mypkg) is not None
+ iscache[mypkg] = retval
+ return retval
def dep_getkey(mydep):
"""