pystratum_cli.command.RoutineLoaderCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 18
dl 0
loc 32
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A RoutineLoaderCommand.handle() 0 16 2
1 1
from cleo.helpers import argument
2
3
from pystratum_cli.command.BaseCommand import BaseCommand
4 1
5
6
class RoutineLoaderCommand(BaseCommand):
7
    """
8
    Command for loading stored routines into a database instance from pseudo SQL files.
9
    """
10
    name = 'loader'
11
    description = 'Command for loading stored routines into a database instance from pseudo SQL files.'
12
    arguments = [argument(name='config_file', description='The stratum configuration file.'),
13
                 argument(name='file_names',  description='Sources with stored routines', optional=True, multiple=True)]
14 1
15
    # ------------------------------------------------------------------------------------------------------------------
16
    def handle(self) -> int:
17
        """
18 1
        Executes constants command when StratumCommand is activated.
19
        """
20 1
        self._read_config_file()
21 1
22 1
        factory = self._create_backend_factory()
23
        worker = factory.create_routine_loader_worker(self._config, self._io)
24 1
        file_names = self.argument('file_names')
25 1
26 1
        if not worker:
27 1
            self._io.title('Loader')
28
            self._io.error('Loader command is not implemented by the backend')
29 1
            return -1
30
31
        return worker.execute(file_names)
32
33
# ----------------------------------------------------------------------------------------------------------------------
34