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/packagerules/parser/context/, roverlay/packagerules/actions/
Date: Wed, 28 Aug 2013 09:39:02
Message-Id: 1377678392.13bb5f5b4ee3c40bb76c622e1b28b9c158f6b1c3.dywi@gentoo
1 commit: 13bb5f5b4ee3c40bb76c622e1b28b9c158f6b1c3
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Wed Aug 28 08:26:32 2013 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Wed Aug 28 08:26:32 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=13bb5f5b
7
8 package rule parser: depstr_ignore
9
10 This commit adds syntax/parser-side support for ignoring dependency strings on a
11 per-package level (or group of packages).
12
13 ---
14 roverlay/packagerules/actions/dependencies.py | 34 ++++++++++++--
15 roverlay/packagerules/parser/context/action.py | 64 ++++++++++++++++++++------
16 2 files changed, 79 insertions(+), 19 deletions(-)
17
18 diff --git a/roverlay/packagerules/actions/dependencies.py b/roverlay/packagerules/actions/dependencies.py
19 index 5e597e2..db4671d 100644
20 --- a/roverlay/packagerules/actions/dependencies.py
21 +++ b/roverlay/packagerules/actions/dependencies.py
22 @@ -60,16 +60,36 @@ class DependencyAction (
23 return self.__class__.ACTION_KEYWORD
24 # --- end of get_action_keyword (...) ---
25
26 + def get_virtual_key ( self ):
27 + key = str ( self.depconf.virtual_key )
28 + return None if key == 'all' else key
29 + # --- end of get_virtual_key (...) ---
30 +
31 @roverlay.util.objects.abstractmethod
32 def get_action_arg_str ( self ):
33 pass
34 # --- end of get_action_arg_str (...) ---
35
36 def gen_str ( self, level ):
37 - yield (
38 - ( level * self.INDENT ) + self.get_action_keyword()
39 - + ' ' + str ( self.depconf.virtual_key )
40 - + ' \"' + self.get_action_arg_str() + '\"'
41 + action_keyword = self.get_action_keyword()
42 + action_arg_str = self.get_action_arg_str()
43 + virtual_key = self.get_virtual_key()
44 + indent = level * self.INDENT
45 +
46 +
47 + if virtual_key:
48 + virtual_key = ' ' + virtual_key
49 + else:
50 + virtual_key = ''
51 +
52 + if action_arg_str:
53 + action_arg_str = ' \"' + action_arg_str + '\"'
54 + else:
55 + action_arg_str = ''
56 +
57 + yield "{indent}{action_keyword}{virtual_key}{action_arg_str}".format (
58 + indent=indent, action_keyword=action_keyword,
59 + virtual_key=virtual_key, action_arg_str=action_arg_str
60 )
61 # --- end of gen_str (...) ---
62
63 @@ -141,3 +161,9 @@ class DependencyInjectAction ( DependencyVarAction ):
64 ACTION_KEYWORD = 'add'
65 CATEGORY_KEY = 'extra'
66 # --- end of DependencyInjectAction (...) ---
67 +
68 +class DepStrIgnoreAction ( DependencyVarAction ):
69 + CATEGORY_KEY = 'depres_ignore'
70 + ACTION_KEYWORD = CATEGORY_KEY
71 + CONVERT_VALUE_TO_DEPRESULT = False
72 +# --- end of DepStrIgnoreAction ---
73
74 diff --git a/roverlay/packagerules/parser/context/action.py b/roverlay/packagerules/parser/context/action.py
75 index b81ba1e..284d62e 100644
76 --- a/roverlay/packagerules/parser/context/action.py
77 +++ b/roverlay/packagerules/parser/context/action.py
78 @@ -55,6 +55,17 @@ class RuleActionContext (
79 'keywords' : roverlay.packagerules.actions.evar.KeywordsEvarAction,
80 }
81
82 + # dict ( <keyword> => <depstr action> )
83 + #
84 + KEYWORDS_DEPSTR = {
85 + 'depstr_ignore': (
86 + roverlay.packagerules.actions.dependencies.DepStrIgnoreAction
87 + ),
88 + 'depres_ignore': (
89 + roverlay.packagerules.actions.dependencies.DepStrIgnoreAction
90 + ),
91 + }
92 +
93 # default info set-to/rename actions
94 # using the lazy variant for renaming
95 #
96 @@ -208,7 +219,7 @@ class RuleActionContext (
97 self._add_action (
98 action_cls.from_namespace (
99 self.namespace, key.upper(),
100 - roverlay.strutil.unquote ( value )
101 + roverlay.strutil.unquote ( value ), lino
102 )
103 )
104 else:
105 @@ -272,6 +283,38 @@ class RuleActionContext (
106 return True
107 # --- end of _add_as_info_action (...) ---
108
109 + def _add_as_keyworded_action ( self, keyword, argstr, orig_str, lino ):
110 + if not argstr:
111 + raise ActionNeedsValue ( orig_str )
112 +
113 + elif keyword in self.KEYWORDS_EVAR:
114 + evar_cls = self.KEYWORDS_EVAR [keyword]
115 +
116 + if evar_cls:
117 + self._add_action (
118 + evar_cls ( roverlay.strutil.unquote ( argstr ), lino )
119 + )
120 + return True
121 + # else disabled evar action
122 +
123 + elif keyword in self.KEYWORDS_DEPSTR:
124 + depstr_cls = self.KEYWORDS_DEPSTR [keyword]
125 +
126 + if depstr_cls:
127 + self._add_action (
128 + depstr_cls.from_namespace (
129 + self.namespace, 'all',
130 + roverlay.strutil.unquote ( argstr ),
131 + lino
132 + )
133 + )
134 + return True
135 + # else disabled
136 +
137 + # -- end if
138 + return False
139 + # --- end of _add_as_keyworded_action (...) ---
140 +
141 def feed ( self, _str, lino ):
142 """Feeds this action block with input.
143
144 @@ -314,24 +357,15 @@ class RuleActionContext (
145 )
146 )
147
148 - elif len ( argv ) > 1 and (
149 - self._add_as_info_action ( argv[0], argv[1], _str, lino )
150 + elif len ( argv ) > 1 and argv[0] and (
151 + self._add_as_info_action ( argv[0], argv[1], _str, lino ) or
152 + self._add_as_keyworded_action ( argv[0], argv[1], _str, lino )
153 ):
154 + # "and argv[0]" not strictly necessary here
155 pass
156
157 else:
158 - evar_cls = self.KEYWORDS_EVAR.get ( argv [0], None )
159 -
160 - try:
161 - if evar_cls:
162 - self._add_action (
163 - evar_cls ( roverlay.strutil.unquote ( argv [1] ), lino )
164 - )
165 - else:
166 - raise ActionUnknown ( _str )
167 -
168 - except IndexError:
169 - raise ActionNeedsValue ( _str )
170 + raise ActionUnknown ( _str )
171 # --- end of feed (...) ---
172
173 def create ( self ):