Completed
Push — master ( 50ed4d...e41221 )
by P.R.
02:44
created

PartNode.get_hierarchy_level()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
ccs 1
cts 2
cp 0.5
rs 9.4285
c 1
b 0
f 0
cc 1
crap 1.125
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9 1
from sdoc.sdoc2.NodeStore import NodeStore
10 1
from sdoc.sdoc2.node.HeadingNode import HeadingNode
11 1
from sdoc.sdoc2.helper.Enumerable import Enumerable
12
13
14 1
class PartNode(HeadingNode):
15
    """
16
    SDoc2 node for parts.
17
    """
18
19
    # ------------------------------------------------------------------------------------------------------------------
20 1
    def __init__(self, io, options, argument):
21
        """
22
        PartNode constructor
23
24
        :param None|cleo.styles.output_style.OutputStyle io: The IO object.
25
        :param dict[str, str] options: The options of this part.
26
        :param str argument: The title of this part.
27
        """
28
        super().__init__(io, 'part', options, argument)
29
30
    # ------------------------------------------------------------------------------------------------------------------
31 1
    def get_command(self):
32
        """
33
        Returns command of this node (i.e. 'part').
34
35
        :rtype: str
36
        """
37
        return 'part'
38
39
    # ------------------------------------------------------------------------------------------------------------------
40 1
    def get_hierarchy_level(self, parent_hierarchy_level=-1):
41
        """
42
        Returns 0.
43
44
        :rtype: int
45
        """
46
        return 0
47
48
    # ------------------------------------------------------------------------------------------------------------------
49 1
    def number(self, enumerable_numbers):
50
        """
51
        Sets number of heading nodes.
52
53
        :param dict[str,sdoc.sdoc2.helper.Enumerable.Enumerable] enumerable_numbers:
54
        """
55
        if 'part' not in enumerable_numbers:
56
            enumerable_numbers['part'] = Enumerable()
57
58
        enumerable_numbers['part'].generate_numeration(self.get_hierarchy_level())
59
        enumerable_numbers['part'].increment_last_level()
60
        enumerable_numbers['part'].remove_starting_zeros()
61
62
        super().number(enumerable_numbers)
63
64
65
# ----------------------------------------------------------------------------------------------------------------------
66
NodeStore.register_inline_command('part', PartNode)
67