airgun.utils
¶
Module Contents¶
Functions¶
|
Update dict values with new values from new_values dict |
|
Transform a widget path:value dict to a regular View read values format. |
|
Return a widget by it's name from widget_root, where widget can be a sub widget. |
|
Decorator to invoke method one or more times, if TimedOutError is raised. |
- airgun.utils.merge_dict(values, new_values)¶
Update dict values with new values from new_values dict
Merge example:
a = {‘a’: {‘c’: {‘k’: 2, ‘x’: {1: 0}}}} b = {‘a’: {‘c’: {‘z’: 5, ‘y’: 40, ‘x’: {2: 1}}}, ‘b’: {‘a’: 1, ‘l’: 2}} update_dict(a, b) # a updated and equal: # {‘a’: {‘c’: {‘k’: 2, ‘x’: {1: 0, 2: 1}, ‘z’: 5, ‘y’: 40}}, ‘b’: {‘a’: 1, ‘l’: 2}}
- airgun.utils.normalize_dict_values(values)¶
Transform a widget path:value dict to a regular View read values format.
- This function transform a dictionary from:
{‘a.b’: 1, ‘a.z’: 10, ‘a.c.k’: 2, ‘a.c.z’: 5, ‘x.y’: 3, ‘c’: 4}
- to:
{‘a’: {‘b’: 1, ‘z’: 10, ‘c’: {‘k’: 2, ‘z’: 5}}, ‘x’: {‘y’: 3}, ‘c’: 4}
- airgun.utils.get_widget_by_name(widget_root, widget_name)¶
Return a widget by it’s name from widget_root, where widget can be a sub widget.
- Parameters
widget_root – The root Widget instance from where to begin resolving widget_name.
widget_name – a string representation of the widget instance to find.
Example
widget_name = ‘details’ or widget_name = ‘details.subscription_status’ or widget_name = ‘details.subscriptions.resources’
Decorator to invoke method one or more times, if TimedOutError is raised.