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

PartNode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 35.7%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
dl 0
loc 49
ccs 5
cts 14
cp 0.357
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get_hierarchy_level() 0 7 1
A number() 0 14 2
A get_command() 0 7 1
A __init__() 0 9 1
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