Passed
Push — master ( 8ff2fc...2dab2b )
by P.R.
04:18 queued 10s
created

sdoc.sdoc2.node.PartNode.PartNode.__init__()   A

Complexity

Conditions 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
eloc 2
dl 9
loc 9
ccs 1
cts 2
cp 0.5
rs 10
c 0
b 0
f 0
cc 1
nop 4
crap 1.125
1 1
from typing import Any, Dict
2
3 1
from cleo.styles import OutputStyle
4
5 1
from sdoc.sdoc2.helper.Enumerable import Enumerable
6 1
from sdoc.sdoc2.node.HeadingNode import HeadingNode
7 1
from sdoc.sdoc2.NodeStore import NodeStore
8
9
10 1 View Code Duplication
class PartNode(HeadingNode):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
    """
12
    SDoc2 node for parts.
13
    """
14
15
    # ------------------------------------------------------------------------------------------------------------------
16 1
    def __init__(self, io: OutputStyle, options: Dict[str, str], argument: str):
17
        """
18
        PartNode constructor
19
20
        :param OutputStyle io: The IO object.
21
        :param dict[str, str] options: The options of this part.
22
        :param str argument: The title of this part.
23
        """
24
        super().__init__(io, 'part', options, argument)
25
26
    # ------------------------------------------------------------------------------------------------------------------
27 1
    def get_command(self) -> str:
28
        """
29
        Returns command of this node (i.e. 'part').
30
        """
31
        return 'part'
32
33
    # ------------------------------------------------------------------------------------------------------------------
34 1
    def get_hierarchy_level(self, parent_hierarchy_level: int = -1) -> int:
35
        """
36
        Returns 0.
37
        """
38
        return 0
39
40
    # ------------------------------------------------------------------------------------------------------------------
41 1
    def number(self, enumerable_numbers: Dict[str, Any]) -> None:
42
        """
43
        Sets number of heading nodes.
44
45
        :param dict[str,any] enumerable_numbers:
46
        """
47
        if 'part' not in enumerable_numbers:
48
            enumerable_numbers['part'] = Enumerable()
49
50
        enumerable_numbers['part'].generate_numeration(self.get_hierarchy_level())
51
        enumerable_numbers['part'].increment_last_level()
52
        enumerable_numbers['part'].remove_starting_zeros()
53
54
        super().number(enumerable_numbers)
55
56
57
# ----------------------------------------------------------------------------------------------------------------------
58
NodeStore.register_inline_command('part', PartNode)
59