This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def flatten_dict(d): | |
| def expand(key, value): | |
| if isinstance(value, dict): | |
| return [(key + '.' + k, v) for k, v in flatten_dict(value).items()] | |
| else: | |
| return [(key, value)] | |
| items = [item for k, v in d.items() for item in expand(k, v)] | |
| return dict(items) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from enum import Enum | |
| class TupleEnum(Enum): | |
| @classmethod | |
| def tuple(cls): | |
| return tuple(((elem.name, elem.value) for elem in cls)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| from logger import log_level | |
| def message(self, message): | |
| with log_level(logging.INFO, __name__) as logger: | |
| input_args = [EXECUTABLE_NAME, SEND_COMMAND] | |
| try: | |
| process = subprocess.Popen(input_args, | |
| stdout=subprocess.PIPE, | |
| stdin=subprocess.PIPE, |
NewerOlder