commit: 093b182951ad7ab6eb7e519061c7b95dc218aacb Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Thu Jul 17 19:14:21 2014 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Thu Jul 17 19:14:21 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=093b1829
overlay/abccontrol: convert_str() --- roverlay/overlay/abccontrol.py | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/roverlay/overlay/abccontrol.py b/roverlay/overlay/abccontrol.py index 364a083..d031eec 100644 --- a/roverlay/overlay/abccontrol.py +++ b/roverlay/overlay/abccontrol.py @@ -82,17 +82,37 @@ class AdditionControlResult ( object ): ) = _gen_bits(5) -# PKG_DESCRIPTION_MAP = { -# PKG_FORCE_DENY : 'force-deny', -# PKG_DENY_REPLACE : 'deny-replace', -# PKG_FORCE_REPLACE : 'force-replace', -# PKG_REPLACE_ONLY : 'replace-only', -# PKG_REVBUMP_ON_COLLISION : 'revbump-on-collision', -# PKG_DEFAULT_BEHAVIOR : 'default', -# } -# -# PKG_DESCRIPTION_REVMAP = { v: k for k,v in PKG_DESCRIPTION_MAP.items() } -# + PKG_DESCRIPTION_MAP = { + PKG_FORCE_DENY : 'force-deny', + PKG_DENY_REPLACE : 'deny-replace', + PKG_FORCE_REPLACE : 'force-replace', + PKG_REPLACE_ONLY : 'replace-only', + PKG_REVBUMP_ON_COLLISION : 'revbump-on-collision', + PKG_DEFAULT_BEHAVIOR : 'default', + } + + PKG_DESCRIPTION_REVMAP = { v: k for k,v in PKG_DESCRIPTION_MAP.items() } + + @classmethod + def convert_str ( cls, s ): + desc_rmap = cls.PKG_DESCRIPTION_REVMAP + + if not s: + raise ValueError ( "str must not be empty." ) + + bitmask = 0 + + for arg in filter ( None, s.strip().lower().split(",") ): + # ^ strip(),lower(),split() ... + print(arg) + try: + bitmask |= desc_rmap [arg] + except KeyError: + raise ValueError ( arg ) + # -- end for + + return bitmask + # --- end of convert_str (...) --- @classmethod def get_reversed_sort_key ( cls, k ):