From b675892c7f75112fb845a8e24bd5be0148b85406 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 8 Sep 2009 08:10:10 +0000 Subject: Reimplement isspecific() using a single regular expression match. Thanks to Marat Radchenko for this patch. svn path=/main/trunk/; revision=14217 --- pym/portage/dep.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'pym') 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): """ -- cgit v1.2.3-1-g7c22