1 |
commit: 1be81df9840f60ba4e9a354e191df7295f4b2c12 |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Mon Jul 30 15:49:36 2012 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Mon Jul 30 15:53:31 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=1be81df9 |
7 |
|
8 |
depenv: regex changes |
9 |
|
10 |
--- |
11 |
roverlay/depres/depenv.py | 27 +++++++++++++++++++-------- |
12 |
1 files changed, 19 insertions(+), 8 deletions(-) |
13 |
|
14 |
diff --git a/roverlay/depres/depenv.py b/roverlay/depres/depenv.py |
15 |
index e70c6d3..f9bef8c 100644 |
16 |
--- a/roverlay/depres/depenv.py |
17 |
+++ b/roverlay/depres/depenv.py |
18 |
@@ -7,14 +7,12 @@ from roverlay import strutil |
19 |
class DepEnv ( object ): |
20 |
|
21 |
# excluding A-Z since dep_str_low will be used to find a match |
22 |
- _NAME = '(?P<name>[a-z0-9_\-/.+-]+)' |
23 |
+ # _NAME ::= word{<whitespace><word>} |
24 |
+ _NAME = '(?P<name>[a-z0-9_\-/.+-]+(\s+[a-z0-9_\-/.+-]+)*)' |
25 |
_VER = '(?P<ver>[0-9._\-]+)' |
26 |
- # { <, >, ==, <=, >=, =, != } (TODO !=) |
27 |
+ # { <, >, ==, <=, >=, =, != } |
28 |
_VERMOD = '(?P<vmod>[<>]|[=<>!]?[=])' |
29 |
|
30 |
- # FIXME: "boost library (>1.0)" not resolved as >=dev-libs/boost-1.0, |
31 |
- # regex \s |
32 |
- |
33 |
V_REGEX_STR = frozenset ( ( |
34 |
# 'R >= 2.15', 'R >=2.15' etc. (but not 'R>=2.15'!) |
35 |
'^{name}\s+{vermod}?\s*{ver}\s*$'.format ( |
36 |
@@ -40,12 +38,25 @@ class DepEnv ( object ): |
37 |
re.compile ( regex ) for regex in V_REGEX_STR |
38 |
) |
39 |
FIXVERSION_REGEX = re.compile ( '[_\-]' ) |
40 |
+ |
41 |
+ URI_PURGE = re.compile ( '\s*from\s*(http|ftp|https)://[^\s]+' ) |
42 |
+ WHITESPACE = re.compile ( '\s+' ) |
43 |
+ |
44 |
TRY_ALL_REGEXES = False |
45 |
|
46 |
STATUS_UNDONE = 1 |
47 |
STATUS_RESOLVED = 2 |
48 |
STATUS_UNRESOLVABLE = 4 |
49 |
|
50 |
+ def _depstr_fix ( self, dep_str ): |
51 |
+ cls = self.__class__ |
52 |
+ return cls.WHITESPACE.sub ( ' ', |
53 |
+ cls.URI_PURGE.sub ( '', |
54 |
+ strutil.unquote ( dep_str ) |
55 |
+ ) |
56 |
+ ).strip() |
57 |
+ # --- end of _depstr_fix (...) --- |
58 |
+ |
59 |
def __init__ ( self, dep_str, deptype_mask ): |
60 |
"""Initializes a dependency environment that represents the dependency |
61 |
resolution of one entry in the description data of an R package. |
62 |
@@ -56,16 +67,16 @@ class DepEnv ( object ): |
63 |
* dep_str -- dependency string at it appears in the description data. |
64 |
""" |
65 |
self.deptype_mask = deptype_mask |
66 |
- self.dep_str = strutil.unquote ( dep_str ) |
67 |
- self.dep_str_low = self.dep_str.lower() |
68 |
self.status = DepEnv.STATUS_UNDONE |
69 |
self.resolved_by = None |
70 |
|
71 |
+ self.dep_str = self._depstr_fix ( dep_str ) |
72 |
+ self.dep_str_low = self.dep_str.lower() |
73 |
+ |
74 |
self.try_all_regexes = self.__class__.TRY_ALL_REGEXES |
75 |
|
76 |
self._depsplit() |
77 |
|
78 |
- |
79 |
# TODO: analyze dep_str: |
80 |
# extract dep name, dep version, useless comments,... |