1 | #!/usr/bin/env python |
||
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | import logging |
||
5 | logger = logging.getLogger(__name__) |
||
6 | logger.debug("%s loaded", __name__) |
||
7 | |||
8 | def get(*args, **kwargs): |
||
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
9 | try: |
||
10 | if len(kwargs['name']) == 0: kwargs['name'] = [''] |
||
11 | if len(kwargs['value']) == 0: kwargs['value'] = [''] |
||
12 | return_dict = {} |
||
13 | for section_request in kwargs['name']: |
||
14 | for section in kwargs['DoorPiObject'].config.get_sections(section_request): |
||
15 | return_dict[section] = {} |
||
16 | for value_request in kwargs['value']: |
||
17 | for key in kwargs['DoorPiObject'].config.get_keys(section, value_request): |
||
18 | return_dict[section][key] = kwargs['DoorPiObject'].config.get(section, key) |
||
19 | |||
20 | for section in return_dict.keys(): |
||
21 | if len(return_dict[section]) == 0: del return_dict[section] |
||
22 | |||
23 | return return_dict |
||
24 | except Exception as exp: |
||
25 | logger.exception(exp) |
||
26 | return {'Error': 'could not create '+str(__name__)+' object - '+str(exp)} |
||
27 | |||
28 | def is_active(doorpi_object): |
||
29 | return True if doorpi_object.config else False |
||
30 |