Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r14217 - main/trunk/pym/portage
Date: Tue, 08 Sep 2009 08:10:12
Message-Id: E1MkvmE-0005Px-E6@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-09-08 08:10:10 +0000 (Tue, 08 Sep 2009)
3 New Revision: 14217
4
5 Modified:
6 main/trunk/pym/portage/dep.py
7 Log:
8 Reimplement isspecific() using a single regular expression match. Thanks to
9 Marat Radchenko <marat@××××××××××××.org> for this patch.
10
11
12 Modified: main/trunk/pym/portage/dep.py
13 ===================================================================
14 --- main/trunk/pym/portage/dep.py 2009-09-08 08:07:03 UTC (rev 14216)
15 +++ main/trunk/pym/portage/dep.py 2009-09-08 08:10:10 UTC (rev 14217)
16 @@ -853,6 +853,7 @@
17 _cp = _cat + '/' + _pkg
18 _cpv = _cp + '-' + _version
19
20 +_cpv_re = re.compile('^' + _cpv + '$')
21 _atom_re = re.compile(r'^(' +
22 '(' + _op + _cpv + _slot + _use + ')|' +
23 '(=' + _cpv + r'\*' + _slot + _use + ')|' +
24 @@ -932,27 +933,24 @@
25
26 Example usage:
27 >>> isspecific('media-libs/test')
28 - 0
29 + False
30 >>> isspecific('media-libs/test-3.0')
31 - 1
32 + True
33
34 @param mypkg: The package depstring to check against
35 @type mypkg: String
36 - @rtype: Integer
37 + @rtype: Boolean
38 @return: One of the following:
39 - 1) 0 if the package string is not specific
40 - 2) 1 if it is
41 + 1) False if the package string is not specific
42 + 2) True if it is
43 """
44 try:
45 return iscache[mypkg]
46 except KeyError:
47 pass
48 - mysplit = mypkg.split("/")
49 - if not isjustname(mysplit[-1]):
50 - iscache[mypkg] = 1
51 - return 1
52 - iscache[mypkg] = 0
53 - return 0
54 + retval = _cpv_re.match(mypkg) is not None
55 + iscache[mypkg] = retval
56 + return retval
57
58 def dep_getkey(mydep):
59 """