Completed
Pull Request — master (#40)
by Wojtek
07:47
created

GroupingStrategy.define_group()   A

Complexity

Conditions 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
1
"""Class represents grouping strategy."""
2
3
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
0 ignored issues
show
Unused Code introduced by
Unnecessary pass statement
Loading history...
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):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
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):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
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