Passed
Push — master ( dbdfc9...f5fa38 )
by P.R.
03:36
created

EnarkshStyle.log_very_verbose()   A

Complexity

Conditions 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 8
ccs 0
cts 3
cp 0
crap 6
rs 9.4285
1
"""
2
Enarksh
3
4
Copyright 2013-2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
from cleo import Output
9
from cleo import OutputFormatterStyle
10
from cleo.styles import CleoStyle
11
12
13
class EnarkshStyle(CleoStyle):
14
    """
15
    Output style for Enarksh.
16
    """
17
18
    # ------------------------------------------------------------------------------------------------------------------
19
    def __init__(self, input, output):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in input.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
20
        """
21
        Object constructor.
22
23
        :param cleo.inputs.input.Input input: The input object.
24
        :param cleo.outputs.output.Output output: The output object.
25
        """
26
        CleoStyle.__init__(self, input, output)
27
28
        # Style for file system objects (e.g. file and directory names).
29
        style = OutputFormatterStyle('green', None, ['bold'])
30
        output.get_formatter().set_style('fso', style)
31
32
        # Style for errors.
33
        style = OutputFormatterStyle('red', None, ['bold'])
34
        output.get_formatter().set_style('err', style)
35
36
        # Style for warnings.
37
        style = OutputFormatterStyle('yellow', None, ['bold'])
38
        output.get_formatter().set_style('warn', style)
39
40
        # Style for Enarksh notices.
41
        style = OutputFormatterStyle('yellow')
42
        output.get_formatter().set_style('notice', style)
43
44
    # ------------------------------------------------------------------------------------------------------------------
45
    def log_verbose(self, message):
46
        """
47
        Logs a message only when logging level is verbose.
48
49
        :param str|list[str] message: The message.
50
        """
51
        if self.get_verbosity() >= Output.VERBOSITY_VERBOSE:
52
            self.writeln(message)
53
54
    # ------------------------------------------------------------------------------------------------------------------
55
    def log_very_verbose(self, message):
56
        """
57
        Logs a message only when logging level is very verbose.
58
59
        :param str|list[str] message: The message.
60
        """
61
        if self.get_verbosity() >= Output.VERBOSITY_VERY_VERBOSE:
62
            self.writeln(message)
63
64
# ----------------------------------------------------------------------------------------------------------------------
65