1 |
Author: zmedico |
2 |
Date: 2009-09-08 08:07:03 +0000 (Tue, 08 Sep 2009) |
3 |
New Revision: 14216 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/dep.py |
7 |
main/trunk/pym/portage/tests/dep/test_isvalidatom.py |
8 |
Log: |
9 |
Fix isvalidatom() to check the 'must not end in' clause from PMS 2.1.2. |
10 |
Thanks to Marat Radchenko <marat@××××××××××××.org> for this patch. |
11 |
|
12 |
|
13 |
Modified: main/trunk/pym/portage/dep.py |
14 |
=================================================================== |
15 |
--- main/trunk/pym/portage/dep.py 2009-09-08 01:51:26 UTC (rev 14215) |
16 |
+++ main/trunk/pym/portage/dep.py 2009-09-08 08:07:03 UTC (rev 14216) |
17 |
@@ -840,8 +840,9 @@ |
18 |
# 2.1.2 A package name may contain any of the characters [A-Za-z0-9+_-]. |
19 |
# It must not begin with a hyphen, |
20 |
# and must not end in a hyphen followed by one or more digits. |
21 |
-# FIXME: this regex doesn't check 'must not end in' clause. |
22 |
-_pkg = r'[A-Za-z0-9+_][A-Za-z0-9+_-]*' |
23 |
+_pkg = r'([A-Za-z+_]+[A-Za-z0-9+_]+|([A-Za-z0-9+_](' + \ |
24 |
+ '[A-Za-z0-9+_-]?|' + \ |
25 |
+ '([A-Za-z0-9+_-]*(([A-Za-z0-9+_][A-Za-z+_-]+)|([A-Za-z+_][A-Za-z0-9+_]+))))))' |
26 |
|
27 |
# 2.1.3 A slot name may contain any of the characters [A-Za-z0-9+_.-]. |
28 |
# It must not begin with a hyphen or a dot. |
29 |
@@ -852,7 +853,7 @@ |
30 |
_cp = _cat + '/' + _pkg |
31 |
_cpv = _cp + '-' + _version |
32 |
|
33 |
-_atom = re.compile(r'^(' + |
34 |
+_atom_re = re.compile(r'^(' + |
35 |
'(' + _op + _cpv + _slot + _use + ')|' + |
36 |
'(=' + _cpv + r'\*' + _slot + _use + ')|' + |
37 |
'(' + _cp + _slot + _use + ')' + |
38 |
@@ -887,7 +888,7 @@ |
39 |
atom = atom[2:] |
40 |
else: |
41 |
atom = atom[1:] |
42 |
- if _atom.match(atom) is None: |
43 |
+ if _atom_re.match(atom) is None: |
44 |
return False |
45 |
try: |
46 |
use = dep_getusedeps(atom) |
47 |
|
48 |
Modified: main/trunk/pym/portage/tests/dep/test_isvalidatom.py |
49 |
=================================================================== |
50 |
--- main/trunk/pym/portage/tests/dep/test_isvalidatom.py 2009-09-08 01:51:26 UTC (rev 14215) |
51 |
+++ main/trunk/pym/portage/tests/dep/test_isvalidatom.py 2009-09-08 08:07:03 UTC (rev 14216) |
52 |
@@ -62,13 +62,22 @@ |
53 |
( ">=null/portage-2.1", True ), |
54 |
( "~null/portage-2.1", True ), |
55 |
( "=null/portage-2.1*", True ), |
56 |
- ( "=foo/bar-123-1", True ), |
57 |
- ( "=foo/bar-123-1-r1", True ), |
58 |
+ |
59 |
+ # These are invalid because pkg name must not end in hyphen |
60 |
+ # followed by numbers |
61 |
+ ( "=foo/bar-123-1", False ), |
62 |
+ ( "=foo/bar-123-1-r1", False ), |
63 |
+ ( "foo/bar-1", False ), |
64 |
+ |
65 |
( "=foo/bar--baz-1-r1", True ), |
66 |
( "=foo/bar-baz--1-r1", True ), |
67 |
( "=foo/bar-baz---1-r1", True ), |
68 |
( "=foo/bar-baz---1", True ), |
69 |
( "=foo/bar-baz-1--r1", False ), |
70 |
+ ( "games-strategy/ufo2000", True ), |
71 |
+ ( "~games-strategy/ufo2000-0.1", True ), |
72 |
+ ( "=media-libs/x264-20060810", True ), |
73 |
+ ( "foo/b", True ), |
74 |
] |
75 |
|
76 |
for test in tests: |