Skip to content
Snippets Groups Projects
Verified Commit 1edbf1f8 authored by Alexander Kreft's avatar Alexander Kreft
Browse files

BUG: Fix bug in retrieve_substructure

parent 2bb76a0e
Branches
Tags
2 merge requests!33MAINT: change arguments of create_user,!16F retrieve substructure
Pipeline #14053 passed with warnings
......@@ -223,6 +223,7 @@ package \"The property P references an instance of D\" <<Rectangle>> {
return result
def retrieve_substructure(start_record_types, depth, result_id_set=None, result_container=None, cleanup=True):
"""Recursively retrieves CaosDB record types and properties, starting
from given initial types up to a specific depth.
......@@ -262,11 +263,11 @@ def retrieve_substructure(start_record_types, depth, result_id_set=None, result_
if is_reference(prop.datatype) and prop.datatype != db.FILE and depth > 0:
rt = db.RecordType(name=get_referenced_recordtype(prop.datatype)).retrieve()
retrieve_substructure([rt], depth-1, result_id_set, result_container, False)
else:
if prop.id not in result_id_set:
result_container.append(prop)
if prop.id not in result_id_set:
result_container.append(prop)
result_id_set.add(prop.id)
for parent in entity.parents:
rt = db.RecordType(id=parent.id).retrieve()
if parent.id not in result_id_set:
......@@ -278,14 +279,14 @@ def retrieve_substructure(start_record_types, depth, result_id_set=None, result_
if cleanup:
return result_container
return None
def to_graphics(recordtypes, filename):
"""Calls recordtypes_to_plantuml_string(), saves result to file and
creates an svg image
plantuml needs to be installed.
Parameters
----------
recordtypes : Iterable[db.Entity]
......@@ -296,7 +297,6 @@ def to_graphics(recordtypes, filename):
"""
pu = recordtypes_to_plantuml_string(recordtypes)
pu_filename = filename+".pu"
with open(pu_filename, "w") as pu_file:
pu_file.write(pu)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment