Add to_directory method to relevant object classes
[oam.git] / code / network-topology-instance-generator / model / python / top.py
1 # Copyright 2022 highstreet technologies GmbH
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 #!/usr/bin/python
16 """
17 Module for an abstract class called "Top".
18 This calls should be inherited for common functions
19 """
20 from lxml import etree
21
22
23 class Top:
24     """
25     The abstract "Top" class adds common functions
26     """
27
28     FONTSIZE: int = 10  # see svg.style.css file
29     __configuration: dict
30     __data: dict
31
32     def __init__(self, configuration) -> None:
33         self.__configuration = configuration
34
35     def configuration(self) -> dict:
36         """
37         Returns the object initial configuration.
38         """
39         raise NotImplementedError('subclasses must override configuration()!')
40
41     def data(self) -> dict:
42         """
43         Returns the class data.
44         """
45         raise NotImplementedError('subclasses must override data()!')
46
47     def identifier(self) -> str:
48         """
49         Returns the name of the class object.
50         """
51         raise NotImplementedError('subclasses must override identifier()!')
52
53     def json(self) -> dict:
54         """
55         Returns the class content in json format.
56         """
57         raise NotImplementedError('subclasses must override json()!')
58
59     def name(self) -> str:
60         """
61         Returns the identifier of the class object.
62         It is preferred a UUID according to RFC4122.
63         """
64         raise NotImplementedError('subclasses must override name()!')
65
66     def svg(self, svg_x: int, svg_y: int) -> etree.Element:
67         """
68         Returns an lxml.etree.Element object.
69         """
70         raise NotImplementedError('subclasses must override svg()!')