aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Erdmann <dywi@mailerd.de>2014-07-17 21:14:21 +0200
committerAndré Erdmann <dywi@mailerd.de>2014-07-17 21:14:21 +0200
commit093b182951ad7ab6eb7e519061c7b95dc218aacb (patch)
treec990e304521283a15f3a0783a2f8e635ceee4426
parentadd-policy rule gen: merge acceptor compounds (diff)
downloadR_overlay-093b182951ad7ab6eb7e519061c7b95dc218aacb.tar.gz
R_overlay-093b182951ad7ab6eb7e519061c7b95dc218aacb.tar.bz2
R_overlay-093b182951ad7ab6eb7e519061c7b95dc218aacb.zip
overlay/abccontrol: convert_str()
-rw-r--r--roverlay/overlay/abccontrol.py42
1 files 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 ):