Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/depres/
Date: Fri, 29 Jun 2012 22:48:48
Message-Id: 1341009274.0fb00e79cfb4e686c8b68d8645b177531e5a7668.dywi@gentoo
1 commit: 0fb00e79cfb4e686c8b68d8645b177531e5a7668
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Fri Jun 29 22:34:34 2012 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Fri Jun 29 22:34:34 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=0fb00e79
7
8 DepEnv: collect more infos about the dep_str
9
10 * using regex for extracting dep name, version, ..
11
12 modified: roverlay/depres/depenv.py
13
14 ---
15 roverlay/depres/depenv.py | 57 +++++++++++++++++++++++++++++++++++++++++++++
16 1 files changed, 57 insertions(+), 0 deletions(-)
17
18 diff --git a/roverlay/depres/depenv.py b/roverlay/depres/depenv.py
19 index 0cb81e8..eba03a8 100644
20 --- a/roverlay/depres/depenv.py
21 +++ b/roverlay/depres/depenv.py
22 @@ -1,6 +1,38 @@
23 # R overlay --
24 # Copyright 2006-2012 Gentoo Foundation
25 # Distributed under the terms of the GNU General Public License v2
26 +import re
27 +
28 +
29 +# excluding A-Z since dep_str_low will be used to find a match
30 +_NAME = '(?P<name>[a-z0-9_\-/]+)'
31 +_VER = '(?P<ver>[0-9._\-]+)'
32 +# { <, >, <=, >=, =, != } (TODO !=)
33 +_VERMOD = '(?P<vmod>[<>]|[<>!]?[=])'
34 +
35 +# this lists ... <fixme>
36 +V_REGEX_STR = frozenset ( (
37 + # 'R >= 2.15', 'R >=2.15' etc. (but not 'R>=2.15'!)
38 + '^%s\s+%s?\s*%s\s*$' % ( _NAME, _VERMOD, _VER ),
39 +
40 + # TODO: merge these regexes: ([{ )]}]
41 +
42 + # 'R (>= 2.15)', 'R(>=2.15)' etc.
43 + '^%s\s*\(%s?\s*%s\s*\)$' % ( _NAME, _VERMOD, _VER ),
44 +
45 + # 'R [>= 2.15]', 'R[>=2.15]' etc.
46 + '^%s\s*\[%s?\s*%s\s*\]$' % ( _NAME, _VERMOD, _VER ),
47 +
48 +
49 + # 'R {>= 2.15}', 'R{>=2.15}' etc.
50 + '^%s\s*\{%s?\s*%s\s*\}$' % ( _NAME, _VERMOD, _VER ),
51 +) )
52 +
53 +VERSION_REGEX = frozenset ( re.compile ( regex ) for regex in V_REGEX_STR )
54 +
55 +FIXVERSION_REGEX = re.compile ( '[_\-]' )
56 +
57 +TRY_ALL_REGEXES = False
58
59
60 class DepEnv ( object ):
61 @@ -22,11 +54,36 @@ class DepEnv ( object ):
62 self.status = DepEnv.STATUS_UNDONE
63 self.resolved_by = None
64
65 + self.try_all_regexes = TRY_ALL_REGEXES
66 +
67 + self._depsplit()
68 +
69 +
70 # TODO: analyze dep_str:
71 # extract dep name, dep version, useless comments,...
72
73 # --- end of __init__ (...) ---
74
75 + def _depsplit ( self ):
76 + result = list()
77 + for r in VERSION_REGEX:
78 + m = r.match ( self.dep_str_low )
79 + if m is not None:
80 +
81 + result.append ( dict (
82 + name = m.group ( 'name' ),
83 + version_modifier = m.group ( 'vmod' ),
84 + version = FIXVERSION_REGEX.sub (
85 + '.', m.group ( 'ver' )
86 + )
87 + ) )
88 +
89 + if not self.try_all_regexes: break
90 +
91 + if result:
92 + self.fuzzy = tuple ( result )
93 + # --- end of _depsplit (...) ---
94 +
95 def set_resolved ( self, resolved_by, append=False ):
96 """Marks this DepEnv as resolved with resolved_by as corresponding
97 portage package.