pystratum_cli.command.StratumCommand   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 86.36%

Importance

Changes 0
Metric Value
wmc 7
eloc 27
dl 0
loc 47
ccs 19
cts 22
cp 0.8636
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B StratumCommand.handle() 0 32 7
1 1
from cleo.helpers import argument
2
3
from pystratum_cli.command.BaseCommand import BaseCommand
4 1
5
6
class StratumCommand(BaseCommand):
7
    """
8
    The stratum command: combination of constants, loader, and wrapper commands.
9
    """
10
    name = 'stratum'
11
    description = 'Generates constants based on database IDs.'
12
    arguments = [argument(name='config_file', description='The stratum configuration file.')]
13 1
14
    # ------------------------------------------------------------------------------------------------------------------
15
    def handle(self) -> int:
16
        """
17 1
        Executes constants command when StratumCommand is activated.
18
        """
19 1
        self._read_config_file()
20
21 1
        factory = self._create_backend_factory()
22 1
23 1
        worker = factory.create_constant_worker(self._config, self._io)
24
        if worker:
25 1
            ret = worker.execute()
26
27
            if ret != 0:
28 1
                return ret
29 1
30 1
        worker = factory.create_routine_loader_worker(self._config, self._io)
31
        if worker:
32 1
            ret = worker.execute()
33
34
            if ret != 0:
35 1
                return ret
36 1
37 1
        worker = factory.create_routine_wrapper_generator_worker(self._config, self._io)
38
        if worker:
39 1
            ret = worker.execute()
40
41
            if ret != 0:
42 1
                return ret
43
44 1
        self._io.write('')
45
46
        return 0
47
48
# ----------------------------------------------------------------------------------------------------------------------
49