From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/, roverlay/packagerules/actions/
Date: Wed, 28 Aug 2013 09:38:56 +0000 (UTC) [thread overview]
Message-ID: <1377678392.13bb5f5b4ee3c40bb76c622e1b28b9c158f6b1c3.dywi@gentoo> (raw)
commit: 13bb5f5b4ee3c40bb76c622e1b28b9c158f6b1c3
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Aug 28 08:26:32 2013 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Aug 28 08:26:32 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=13bb5f5b
package rule parser: depstr_ignore
This commit adds syntax/parser-side support for ignoring dependency strings on a
per-package level (or group of packages).
---
roverlay/packagerules/actions/dependencies.py | 34 ++++++++++++--
roverlay/packagerules/parser/context/action.py | 64 ++++++++++++++++++++------
2 files changed, 79 insertions(+), 19 deletions(-)
diff --git a/roverlay/packagerules/actions/dependencies.py b/roverlay/packagerules/actions/dependencies.py
index 5e597e2..db4671d 100644
--- a/roverlay/packagerules/actions/dependencies.py
+++ b/roverlay/packagerules/actions/dependencies.py
@@ -60,16 +60,36 @@ class DependencyAction (
return self.__class__.ACTION_KEYWORD
# --- end of get_action_keyword (...) ---
+ def get_virtual_key ( self ):
+ key = str ( self.depconf.virtual_key )
+ return None if key == 'all' else key
+ # --- end of get_virtual_key (...) ---
+
@roverlay.util.objects.abstractmethod
def get_action_arg_str ( self ):
pass
# --- end of get_action_arg_str (...) ---
def gen_str ( self, level ):
- yield (
- ( level * self.INDENT ) + self.get_action_keyword()
- + ' ' + str ( self.depconf.virtual_key )
- + ' \"' + self.get_action_arg_str() + '\"'
+ action_keyword = self.get_action_keyword()
+ action_arg_str = self.get_action_arg_str()
+ virtual_key = self.get_virtual_key()
+ indent = level * self.INDENT
+
+
+ if virtual_key:
+ virtual_key = ' ' + virtual_key
+ else:
+ virtual_key = ''
+
+ if action_arg_str:
+ action_arg_str = ' \"' + action_arg_str + '\"'
+ else:
+ action_arg_str = ''
+
+ yield "{indent}{action_keyword}{virtual_key}{action_arg_str}".format (
+ indent=indent, action_keyword=action_keyword,
+ virtual_key=virtual_key, action_arg_str=action_arg_str
)
# --- end of gen_str (...) ---
@@ -141,3 +161,9 @@ class DependencyInjectAction ( DependencyVarAction ):
ACTION_KEYWORD = 'add'
CATEGORY_KEY = 'extra'
# --- end of DependencyInjectAction (...) ---
+
+class DepStrIgnoreAction ( DependencyVarAction ):
+ CATEGORY_KEY = 'depres_ignore'
+ ACTION_KEYWORD = CATEGORY_KEY
+ CONVERT_VALUE_TO_DEPRESULT = False
+# --- end of DepStrIgnoreAction ---
diff --git a/roverlay/packagerules/parser/context/action.py b/roverlay/packagerules/parser/context/action.py
index b81ba1e..284d62e 100644
--- a/roverlay/packagerules/parser/context/action.py
+++ b/roverlay/packagerules/parser/context/action.py
@@ -55,6 +55,17 @@ class RuleActionContext (
'keywords' : roverlay.packagerules.actions.evar.KeywordsEvarAction,
}
+ # dict ( <keyword> => <depstr action> )
+ #
+ KEYWORDS_DEPSTR = {
+ 'depstr_ignore': (
+ roverlay.packagerules.actions.dependencies.DepStrIgnoreAction
+ ),
+ 'depres_ignore': (
+ roverlay.packagerules.actions.dependencies.DepStrIgnoreAction
+ ),
+ }
+
# default info set-to/rename actions
# using the lazy variant for renaming
#
@@ -208,7 +219,7 @@ class RuleActionContext (
self._add_action (
action_cls.from_namespace (
self.namespace, key.upper(),
- roverlay.strutil.unquote ( value )
+ roverlay.strutil.unquote ( value ), lino
)
)
else:
@@ -272,6 +283,38 @@ class RuleActionContext (
return True
# --- end of _add_as_info_action (...) ---
+ def _add_as_keyworded_action ( self, keyword, argstr, orig_str, lino ):
+ if not argstr:
+ raise ActionNeedsValue ( orig_str )
+
+ elif keyword in self.KEYWORDS_EVAR:
+ evar_cls = self.KEYWORDS_EVAR [keyword]
+
+ if evar_cls:
+ self._add_action (
+ evar_cls ( roverlay.strutil.unquote ( argstr ), lino )
+ )
+ return True
+ # else disabled evar action
+
+ elif keyword in self.KEYWORDS_DEPSTR:
+ depstr_cls = self.KEYWORDS_DEPSTR [keyword]
+
+ if depstr_cls:
+ self._add_action (
+ depstr_cls.from_namespace (
+ self.namespace, 'all',
+ roverlay.strutil.unquote ( argstr ),
+ lino
+ )
+ )
+ return True
+ # else disabled
+
+ # -- end if
+ return False
+ # --- end of _add_as_keyworded_action (...) ---
+
def feed ( self, _str, lino ):
"""Feeds this action block with input.
@@ -314,24 +357,15 @@ class RuleActionContext (
)
)
- elif len ( argv ) > 1 and (
- self._add_as_info_action ( argv[0], argv[1], _str, lino )
+ elif len ( argv ) > 1 and argv[0] and (
+ self._add_as_info_action ( argv[0], argv[1], _str, lino ) or
+ self._add_as_keyworded_action ( argv[0], argv[1], _str, lino )
):
+ # "and argv[0]" not strictly necessary here
pass
else:
- evar_cls = self.KEYWORDS_EVAR.get ( argv [0], None )
-
- try:
- if evar_cls:
- self._add_action (
- evar_cls ( roverlay.strutil.unquote ( argv [1] ), lino )
- )
- else:
- raise ActionUnknown ( _str )
-
- except IndexError:
- raise ActionNeedsValue ( _str )
+ raise ActionUnknown ( _str )
# --- end of feed (...) ---
def create ( self ):
next reply other threads:[~2013-08-28 9:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-28 9:38 André Erdmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-09-05 15:43 [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/, roverlay/packagerules/actions/ André Erdmann
2013-08-28 9:38 André Erdmann
2013-08-23 13:52 André Erdmann
2013-08-19 15:42 André Erdmann
2013-04-25 16:44 André Erdmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377678392.13bb5f5b4ee3c40bb76c622e1b28b9c158f6b1c3.dywi@gentoo \
--to=dywi@mailerd.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox