From 4b2036bf22502086e18f08337c5c76eb4428c151 Mon Sep 17 00:00:00 2001 From: demx8as6 Date: Mon, 21 Feb 2022 15:50:26 +0100 Subject: [PATCH] Create a script to generate a Topology - defines most abstract Topology class IssueID: OAM-249 Change-Id: Idd7ec1d47aac4cc597076e3bc184dcb1b71d6b71 Signed-off-by: demx8as6 --- .../model/python/top.py | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 code/network-topology-instance-generator/model/python/top.py diff --git a/code/network-topology-instance-generator/model/python/top.py b/code/network-topology-instance-generator/model/python/top.py new file mode 100644 index 0000000..359976d --- /dev/null +++ b/code/network-topology-instance-generator/model/python/top.py @@ -0,0 +1,70 @@ +# Copyright 2022 highstreet technologies GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/usr/bin/python +""" +Module for an abstract class called "Top". +This calls should be inherited for common functions +""" +from lxml import etree + + +class Top: + """ + The abstract "Top" class adds common functions + """ + + FONTSIZE: int = 10 # see svg.style.css file + __configuration: dict + __data: dict + + def __init__(self, configuration) -> None: + self.__configuration = configuration + + def configuration(self) -> dict: + """ + Returns the object initial configuration. + """ + raise NotImplementedError('subclasses must override configuration()!') + + def data(self) -> dict: + """ + Returns the class data. + """ + raise NotImplementedError('subclasses must override data()!') + + def identifier(self) -> str: + """ + Returns the name of the class object. + """ + raise NotImplementedError('subclasses must override identifier()!') + + def json(self) -> dict: + """ + Returns the class content in json format. + """ + raise NotImplementedError('subclasses must override json()!') + + def name(self) -> str: + """ + Returns the identifier of the class object. + It is preferred a UUID according to RFC4122. + """ + raise NotImplementedError('subclasses must override name()!') + + def svg(self, svg_x: int, svg_y: int) -> etree.Element: + """ + Returns an lxml.etree.Element object. + """ + raise NotImplementedError('subclasses must override svg()!') -- 2.16.6