Explorar o código

Add superclass 'Element' to all (non-abstract) AS classes (needed for traceability links)

Joeri Exelmans %!s(int64=2) %!d(string=hai) anos
pai
achega
7265d662de
Modificáronse 1 ficheiros con 11 adicións e 6 borrados
  1. 11 6
      drawio2py/abstract_syntax.py

+ 11 - 6
drawio2py/abstract_syntax.py

@@ -3,12 +3,17 @@ from typing import Optional, List, Dict
 from decimal import Decimal
 import re
 
+# Sub-class of all (non-abstract) Drawio AS classes
 @dataclass
-class Style:
+class Element:
+	pass
+
+@dataclass
+class Style(Element):
 	data: dict[str,str]
 
 @dataclass
-class Cell:
+class Cell(Element):
 	""" Instances of Cell are: the root cell and its layers """
 	id: str
 	value: str
@@ -19,7 +24,7 @@ class Cell:
 	attributes: dict[str,str] # Any extra XML attributes
 
 @dataclass
-class Point:
+class Point(Element):
 	x: Decimal
 	y: Decimal
 
@@ -33,7 +38,7 @@ class Vertex(Cell):
 	geometry: VertexGeometry
 
 @dataclass
-class EdgeGeometry:
+class EdgeGeometry(Element):
 	points: List[Point] = field(default_factory=list)
 	source_point: Optional[Point] = None
 	target_point: Optional[Point] = None
@@ -45,7 +50,7 @@ class Edge(Cell):
 	target: Vertex
 
 @dataclass
-class Page:
+class Page(Element):
 	id: str                   # (Globally unique) ID of the page
 	name: str                 # Page name, as shown in GUI
 	attributes: dict[str,str] # Attributes of the <mxGraphModel> of the page
@@ -58,7 +63,7 @@ class Page:
 		return re.sub(r"[^a-zA-Z0-9_]", "", self.name)
 
 @dataclass
-class DrawIOFile:
+class DrawIOFile(Element):
 	filename: str
 	compressed: bool
 	version: str  # Version of Drawio that created the file