diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-07-02 12:52:31 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-07-14 12:14:20 -0300 |
commit | 0cab909f9518273d95e371e5fb1061fb9b0a92fd (patch) | |
tree | 62d1bd0ea280fa1889a6f84b41cc46a232d2918e /src/leap/bitmask/util/__init__.py | |
parent | 13c0b7cac822a33f7395e3f099a2d37251e2c759 (diff) |
Send the flag module values to the processes.
Add serialize/deserialize to dict helper.
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 |