| Total Complexity | 19 | 
| Total Lines | 73 | 
| Duplicated Lines | 0 % | 
| Changes | 6 | ||
| Bugs | 0 | Features | 2 | 
| 1 | from synergine.core.exception.NotFoundError import NotFoundError | ||
| 4 | class Terminal(): | ||
| 5 | """ | ||
| 6 | Obj who receive synergine data at each cycle | ||
| 7 | """ | ||
| 8 | |||
| 9 | _name = None | ||
| 10 | |||
| 11 | @classmethod | ||
| 12 | def get_name(cls): | ||
| 13 | if not cls._name: | ||
| 14 |             raise Exception("Terminal must be named") | ||
| 15 | return cls._name | ||
| 16 | |||
| 17 | def __init__(self, config, context, synergy_manager): | ||
| 18 | """ | ||
| 19 | |||
| 20 | :param config: ConfigurationManager | ||
| 21 | :return: void | ||
| 22 | """ | ||
| 23 | self._encapsuled_run = False | ||
| 24 | self._config = config | ||
| 25 | self._context = context | ||
| 26 | self._synergy_manager = synergy_manager | ||
| 27 | |||
| 28 | def _get_config(self, config_name, default=None): | ||
| 29 | try: | ||
| 30 |             return self._config.get('terminal.'+self.get_name()+'.'+config_name) | ||
| 31 | except NotFoundError: | ||
| 32 | pass | ||
| 33 | try: | ||
| 34 |             return self._config.get('terminal.__default__.'+config_name) | ||
| 35 | except NotFoundError: | ||
| 36 | pass | ||
| 37 | try: | ||
| 38 | return self._config.get(config_name) | ||
| 39 | except NotFoundError: | ||
| 40 | pass | ||
| 41 | if default is not None: | ||
| 42 | return default | ||
| 43 |         raise NotFoundError("Can't found config ", config_name) | ||
| 44 | |||
| 45 | def encapsulate_run(self, run_function): | ||
| 46 | self._encapsuled_run = True | ||
| 47 | |||
| 48 | def initialize(self): | ||
| 49 | pass | ||
| 50 | |||
| 51 | def have_encapsulated_run(self): | ||
| 52 | return self._encapsuled_run | ||
| 53 | |||
| 54 | def need_to_run_core(self): | ||
| 55 | return False | ||
| 56 | |||
| 57 | def start_of_cycle(self): | ||
| 58 | pass | ||
| 59 | |||
| 60 | def end_of_cycle(self): | ||
| 61 | pass | ||
| 62 | |||
| 63 | def initialize_screen(self, screen): | ||
| 64 | pass | ||
| 65 | |||
| 66 | def receive(self, actions_done): | ||
| 67 | pass | ||
| 68 | |||
| 69 | def terminate(self): | ||
| 70 | pass | ||
| 71 | |||
| 72 | def get_context(self): | ||
| 73 | return self._context | ||
| 74 | |||
| 75 | def get_synergy_manager(self): | ||
| 76 | return self._synergy_manager | ||
| 77 |