| Conditions | 9 |
| Total Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | def gw_get(object_dict, name=None, plugin=None): |
||
| 2 | """ |
||
| 3 | Getter function to retrieve objects from a given object dictionary. |
||
| 4 | |||
| 5 | Used mainly to provide get() inside patterns. |
||
| 6 | |||
| 7 | :param object_dict: objects, which must have 'name' and 'plugin' as attribute |
||
| 8 | :type object_dict: dictionary |
||
| 9 | :param name: name of the object |
||
| 10 | :type name: str |
||
| 11 | :param plugin: plugin name, which registers the object |
||
| 12 | :return: None, single object or dict of objects |
||
| 13 | """ |
||
| 14 | if plugin is not None: |
||
| 15 | if name is None: |
||
| 16 | object_list = {} |
||
| 17 | for key in object_dict.keys(): |
||
| 18 | if object_dict[key].plugin == plugin: |
||
| 19 | object_list[key] = object_dict[key] |
||
| 20 | return object_list |
||
| 21 | else: |
||
| 22 | if name in object_dict.keys(): |
||
| 23 | if object_dict[name].plugin == plugin: |
||
| 24 | return object_dict[name] |
||
| 25 | else: |
||
| 26 | return None |
||
| 27 | else: |
||
| 28 | return None |
||
| 29 | else: |
||
| 30 | if name is None: |
||
| 31 | return object_dict |
||
| 32 | else: |
||
| 33 | if name in object_dict.keys(): |
||
| 34 | return object_dict[name] |
||
| 35 | else: |
||
| 36 | return None |
||
| 37 |