| Total Complexity | 9 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | """Class represents grouping strategy.""" |
||
| 4 | class GroupingStrategy(object): |
||
| 5 | """Class represents grouping strategy.""" |
||
| 6 | |||
| 7 | def __init__(self, ordered_stages): |
||
| 8 | self.ordered_stages = ordered_stages |
||
| 9 | self.groups = {} |
||
| 10 | pass |
||
|
|
|||
| 11 | |||
| 12 | def define_group(self, group_of_stages): |
||
| 13 | """Add group of stages. Those stages will be in the same group. |
||
| 14 | |||
| 15 | Args: |
||
| 16 | group_of_stages (tuple): group of stages""" |
||
| 17 | group_number = self.get_actual_numbers_of_groups() |
||
| 18 | for stage in group_of_stages: |
||
| 19 | if stage in self.groups.keys(): |
||
| 20 | raise ValueError("Stage already added.") |
||
| 21 | else: |
||
| 22 | self.ordered_stages[stage] = group_number |
||
| 23 | |||
| 24 | def get_actual_numbers_of_groups(self): |
||
| 25 | if len(self.groups) == 0: |
||
| 26 | return 0 |
||
| 27 | else: |
||
| 28 | return sorted(self.groups.values())[-1] + 1 |
||
| 29 | |||
| 30 | def get_items_from_the_same_group(self, stage): |
||
| 31 | group_number = self.groups[stage] |
||
| 32 | stages_from_group = [] |
||
| 33 | for cur_stage in self.groups.keys(): |
||
| 34 | if self.groups[cur_stage] == group_number: |
||
| 35 | stages_from_group.append(cur_stage) |
||
| 36 |