| Total Complexity | 6 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| 1 | """Contains factory class of process with calls stages.""" |
||
| 7 | class CallsProcessFactory: |
||
| 8 | """Class which produce process with the same type of stages. |
||
| 9 | |||
| 10 | Attributes: |
||
| 11 | structure_type (str): represent type of structure |
||
| 12 | how_many_nodes (int): how many nodes should be in generated process |
||
| 13 | process (CallsProcess): process which will be incrementally build |
||
| 14 | """ |
||
| 15 | |||
| 16 | def __init__(self, structure_type, how_many_nodes): |
||
| 17 | """Constructor.""" |
||
| 18 | self._stages_to_add = [] |
||
| 19 | self.structure_type = structure_type |
||
| 20 | self.how_many_nodes = how_many_nodes |
||
| 21 | self.process = CallsProcess() |
||
| 22 | |||
| 23 | def _update_structure(self): |
||
| 24 | if "linear" == self.structure_type: |
||
| 25 | self.process.add_path(self._stages_to_add) |
||
| 26 | |||
| 27 | def _create_stages(self): |
||
| 28 | for i in range(self.how_many_nodes): |
||
| 29 | self._stages_to_add += CallsStage() |
||
| 30 | |||
| 31 | def construct_process(self): |
||
| 32 | """Construct process.""" |
||
| 33 | self._create_stages() |
||
| 34 | self._update_structure() |
||
| 35 | return self.process |
||
| 36 |