Skip to content
Snippets Groups Projects
Commit bb02e16d authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

ENH: added util to create svg from structure

parent 74d22ae7
Branches
Tags
No related merge requests found
......@@ -33,6 +33,8 @@ convert it with:
plantuml FILENAME.pu -> FILENAME.png
"""
import os
import caosdb as db
REFERENCE = "REFERENCE"
......@@ -175,3 +177,27 @@ def recordtypes_to_plantuml_string(iterable):
result += "\n@enduml\n"
return result
def to_graphics(recordtypes, filename):
""" calls recordtypes_to_plantuml_string(), saves result to file and
creates an svg image
plantuml needs to be installed
@params:
recordtypes: itrable with the record types to be displayed
filname: filename of the image (e.g. data_structure; data_structure.pu and
data_structure.svg will be created.
"""
pu = recordtypes_to_plantuml_string(recordtypes)
pu_filename = filename+".pu"
with open(pu_filename, "w") as pu_file:
pu_file.write(pu)
cmd = "plantuml -tsvg %s" % pu_filename
print("Executing:", cmd)
if os.system(cmd) != 0:
raise Exception("An error occured during the execution of plantuml. "
"Is plantuml installed?")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment