Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r14219 - in main/trunk/pym/portage: . tests/dep
Date: Tue, 08 Sep 2009 18:11:56
Message-Id: E1Ml5AY-0001yA-AN@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-09-08 18:11:53 +0000 (Tue, 08 Sep 2009)
3 New Revision: 14219
4
5 Modified:
6 main/trunk/pym/portage/dep.py
7 main/trunk/pym/portage/tests/dep/test_isvalidatom.py
8 Log:
9 simplify atom regex (winning even more performance) and turns it in verbose
10 mode with comments. Added more corner case tests. Thanks to Marat Radchenko
11 <marat@××××××××××××.org> for this patch from bug #276813.
12
13
14 Modified: main/trunk/pym/portage/dep.py
15 ===================================================================
16 --- main/trunk/pym/portage/dep.py 2009-09-08 09:11:35 UTC (rev 14218)
17 +++ main/trunk/pym/portage/dep.py 2009-09-08 18:11:53 UTC (rev 14219)
18 @@ -833,32 +833,40 @@
19 open_bracket = depend.find( '[', open_bracket+1 )
20 return tuple(use_list)
21
22 +# \w is [a-zA-Z0-9_]
23 +
24 # 2.1.1 A category name may contain any of the characters [A-Za-z0-9+_.-].
25 # It must not begin with a hyphen or a dot.
26 -_cat = r'[A-Za-z0-9+_][A-Za-z0-9+_.-]*'
27 +_cat = r'[\w+][\w+.-]*'
28
29 # 2.1.2 A package name may contain any of the characters [A-Za-z0-9+_-].
30 # It must not begin with a hyphen,
31 # and must not end in a hyphen followed by one or more digits.
32 -_pkg = r'([A-Za-z+_]+[A-Za-z0-9+_]+|([A-Za-z0-9+_](' + \
33 - '[A-Za-z0-9+_-]?|' + \
34 - '([A-Za-z0-9+_-]*(([A-Za-z0-9+_][A-Za-z+_-]+)|([A-Za-z+_][A-Za-z0-9+_]+))))))'
35 +_pkg = \
36 +r'''([\w+](
37 + -? # All other 2-char are handled by next
38 + |[\w+]* # No hyphens - no problems
39 + |[\w+-]+( # String with a hyphen...
40 + [A-Za-z+_-] # ... must end in nondigit
41 + |[A-Za-z+_][\w+]+ # ... or in nondigit and then nonhyphens
42 + )
43 +))'''
44
45 # 2.1.3 A slot name may contain any of the characters [A-Za-z0-9+_.-].
46 # It must not begin with a hyphen or a dot.
47 -_slot = r'(:[A-Za-z0-9+_][A-Za-z0-9+_.-]*)?'
48 +_slot = r'(:[\w+][\w+.-]*)?'
49
50 _use = r'(\[.*\])?'
51 -_op = r'([=><~]|([><]=))'
52 +_op = r'([=~]|[><]=?)'
53 _cp = _cat + '/' + _pkg
54 _cpv = _cp + '-' + _version
55
56 -_cpv_re = re.compile('^' + _cpv + '$')
57 +_cpv_re = re.compile('^' + _cpv + '$', re.VERBOSE)
58 _atom_re = re.compile(r'^(' +
59 '(' + _op + _cpv + _slot + _use + ')|' +
60 '(=' + _cpv + r'\*' + _slot + _use + ')|' +
61 '(' + _cp + _slot + _use + ')' +
62 - ')$')
63 + ')$', re.VERBOSE)
64
65 def isvalidatom(atom, allow_blockers=False):
66 """
67
68 Modified: main/trunk/pym/portage/tests/dep/test_isvalidatom.py
69 ===================================================================
70 --- main/trunk/pym/portage/tests/dep/test_isvalidatom.py 2009-09-08 09:11:35 UTC (rev 14218)
71 +++ main/trunk/pym/portage/tests/dep/test_isvalidatom.py 2009-09-08 18:11:53 UTC (rev 14219)
72 @@ -78,6 +78,9 @@
73 ( "~games-strategy/ufo2000-0.1", True ),
74 ( "=media-libs/x264-20060810", True ),
75 ( "foo/b", True ),
76 + ( "app-text/7plus", True ),
77 + ( "foo/666", True ),
78 + ( "=dev-libs/poppler-qt3-0.11*", True ),
79 ]
80
81 for test in tests: