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