summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/util/__init__.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-06-12 15:55:12 -0300
committerTomás Touceda <chiiph@leap.se>2014-06-12 15:55:12 -0300
commitdea498f1e09c17b6c86519dd95ea430744ecd30d (patch)
tree2d5a7cb9d13ddf76a92848a17fceb0288dad4fd8 /src/leap/bitmask/util/__init__.py
parentba12b3c46ddd4403a4f860cb18796428f2bd3ffb (diff)
parentd2fc367cc284a87d60bfdc96fcd87e257296ee02 (diff)
Merge remote-tracking branch 'refs/remotes/kali/feature/install-bitmask-root-to-local-path' into develop
Diffstat (limited to 'src/leap/bitmask/util/__init__.py')
-rw-r--r--src/leap/bitmask/util/__init__.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/leap/bitmask/util/__init__.py b/src/leap/bitmask/util/__init__.py
index c35be99e..25b86874 100644
--- a/src/leap/bitmask/util/__init__.py
+++ b/src/leap/bitmask/util/__init__.py
@@ -110,3 +110,22 @@ def make_address(user, provider):
:type provider: basestring
"""
return "%s@%s" % (user, provider)
+
+
+def force_eval(items):
+ """
+ Return a sequence that evaluates any callable in the sequence,
+ instantiating it beforehand if the item is a class, and
+ leaves the non-callable items without change.
+ """
+ def do_eval(thing):
+ if isinstance(thing, type):
+ return thing()()
+ if callable(thing):
+ return thing()
+ return thing
+
+ if isinstance(items, (list, tuple)):
+ return map(do_eval, items)
+ else:
+ return do_eval(items)