Skip to content

Commit b98146e

Browse files
committed
UPD: RavensExport to use RDFGraph class
1 parent 3ff6bfd commit b98146e

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

ravens/xml/ravens2xml.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
from uuid import uuid4
77

88
from rdflib.exceptions import UniquenessError
9-
from rdflib.namespace import Namespace
109
from rdflib.term import URIRef, Literal
11-
from rdflib import Graph, RDF
10+
from rdflib import RDF
1211

1312
from ravens.data import _DEFAULT_CIM_NAMESPACE
1413
from ravens.uml.common import get_names_of_enumeration_classes
1514
from ravens.uml import UMLData
15+
from ravens.xml.graph import RDFGraph
1616

1717

18-
class RavensExport(object):
18+
class RavensExport(RDFGraph):
1919
def __init__(self, data, uml_data: UMLData | None = None, cim_namespace: str = _DEFAULT_CIM_NAMESPACE):
20+
super().__init__(cim_namespace=cim_namespace)
2021
self.data = deepcopy(data)
2122
self.cim_enums = None
2223

@@ -25,10 +26,6 @@ def __init__(self, data, uml_data: UMLData | None = None, cim_namespace: str = _
2526

2627
self.cim_enums = get_names_of_enumeration_classes(uml_data)
2728

28-
self.graph = Graph()
29-
self.cim = Namespace(cim_namespace + "#")
30-
self.graph.bind("cim", self.cim, override=True)
31-
3229
self.build_rdf_graph(self.data)
3330
self.update_uri_refs()
3431
if self.cim_enums is not None:
@@ -114,9 +111,6 @@ def update_enumeration_uri_refs(self):
114111
for triple in triple_to_delete:
115112
self.graph.remove(triple)
116113

117-
def save_cim_profile(self, file_path: pathlib.PosixPath):
118-
self.graph.serialize(file_path, max_depth=1, format="pretty-xml")
119-
120114

121115
if __name__ == "__main__":
122116
pathlib.Path("out").mkdir(parents=True, exist_ok=True)
@@ -125,4 +119,4 @@ def save_cim_profile(self, file_path: pathlib.PosixPath):
125119
d = json.load(f)
126120

127121
r = RavensExport(d)
128-
r.save_cim_profile("out/test_output.xml")
122+
r.save("out/test_output.xml")

0 commit comments

Comments
 (0)