1 | 1 | from typing import Any, Dict |
|
2 | |||
3 | 1 | from cleo.io.io import IO |
|
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
![]() |
|||
11 | """ |
||
12 | SDoc2 node for parts. |
||
13 | """ |
||
14 | |||
15 | # ------------------------------------------------------------------------------------------------------------------ |
||
16 | 1 | def __init__(self, io: IO, 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 |