diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-07-16 16:42:03 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-07-16 16:42:03 -0300 |
commit | 34457adc72a4a4c0b4bff4791f4329bca66162c1 (patch) | |
tree | 279542ab3ce460d1f0bcd7943352c3e792c9f2c6 /src/leap/bitmask/util/__init__.py | |
parent | 4f946ea2189e78da0488a28b3bb8a8aed997a1c5 (diff) | |
parent | 3d6629348aedf2a6863d242d96d64b3492e86f9a (diff) |
Merge remote-tracking branch 'refs/remotes/ivan/feature/new-frontend-backend' into develop
Diffstat (limited to 'src/leap/bitmask/util/__init__.py')
-rw-r--r-- | src/leap/bitmask/util/__init__.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/leap/bitmask/util/__init__.py b/src/leap/bitmask/util/__init__.py index 25b86874..caa94ec7 100644 --- a/src/leap/bitmask/util/__init__.py +++ b/src/leap/bitmask/util/__init__.py @@ -129,3 +129,28 @@ def force_eval(items): return map(do_eval, items) else: return do_eval(items) + + +def dict_to_flags(values): + """ + Set the flags values given in the values dict. + If a value isn't provided then use the already existing one. + + :param values: the values to set. + :type values: dict. + """ + for k, v in values.items(): + setattr(flags, k, v) + + +def flags_to_dict(): + """ + Get the flags values in a dict. + + :return: the values of flags into a dict. + :rtype: dict. + """ + items = [i for i in dir(flags) if i[0] != '_'] + values = {i: getattr(flags, i) for i in items} + + return values |