Passed
Branch master (caaf42)
by P.R.
05:13
created

StratumApplication.render_error()   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nop 3
crap 2
1 1
from cleo.application import Application
2
from cleo.io.io import IO
3 1
from cleo.io.outputs.output import Verbosity
4
from pystratum_backend.StratumIO import StratumIO
5 1
6 1
from pystratum_cli.command.ConstantsCommand import ConstantsCommand
7 1
from pystratum_cli.command.RoutineLoaderCommand import RoutineLoaderCommand
8 1
from pystratum_cli.command.RoutineWrapperCommand import RoutineWrapperCommand
9
from pystratum_cli.command.StratumCommand import StratumCommand
10
11 1
12
class StratumApplication(Application):
13
    """
14
    The PyStratum application.
15
    """
16
17 1
    # ------------------------------------------------------------------------------------------------------------------
18
    def __init__(self):
19
        """
20
        Object constructor
21 1
        """
22
        Application.__init__(self, 'pystratum', '1.0.4')
23
24 1
        self.add(ConstantsCommand())
25
        self.add(RoutineLoaderCommand())
26
        self.add(StratumCommand())
27
        self.add(RoutineWrapperCommand())
28
29
    # ------------------------------------------------------------------------------------------------------------------
30 1
    def render_error(self, error: Exception, io: IO) -> None:
31
        if io.output.verbosity == Verbosity.NORMAL:
32 1
            my_io = StratumIO(io.input, io.output, io.error_output)
33 1
            lines = [error.__class__.__name__, str(error)]
34 1
            my_io.error(lines)
35 1
        else:
36
            Application.render_error(self, error, io)
37 1
38
# ----------------------------------------------------------------------------------------------------------------------
39