Completed
Pull Request — master (#27)
by Wojtek
02:14
created

construct_process()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
cc 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
1
"""Contains factory class of process with calls stages."""
2
3 1
from grortir.main.model.processes.calls_process import CallsProcess
4 1
from grortir.main.model.stages.calls_stage import CallsStage
5
6
7 1
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 1
    def __init__(self, structure_type, how_many_nodes):
17
        """Constructor."""
18 1
        self._stages_to_add = []
19 1
        self.structure_type = structure_type
20 1
        self.how_many_nodes = how_many_nodes
21 1
        self.process = CallsProcess()
22
23 1
    def _update_structure(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...
24 1
        if self.structure_type == "linear":
25 1
            self.process.add_path(self._stages_to_add)
1 ignored issue
show
Bug introduced by
The Instance of CallsProcess does not seem to have a member named add_path.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
26
        else:
27 1
            raise NotImplementedError()
28
29 1
    def _create_stages(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...
30 1
        for i in range(self.how_many_nodes):
31 1
            self._stages_to_add += [CallsStage(str(i))]
32
33 1
    def construct_process(self):
34
        """Construct process."""
35 1
        self._create_stages()
36 1
        self._update_structure()
37
        return self.process
38