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

DOC: add docstring

parent ab1d4796
Branches
Tags
2 merge requests!160STY: styling,!142ENH: add utility function that replaces name strings in values of reference properties with IDs
Pipeline #46348 failed
......@@ -831,6 +831,16 @@ class Crawler(object):
@staticmethod
def replace_name_with_referenced_entity_id(prop: db.Property):
"""changes the given property in place if it is a reference property that has a name as
value
If the Property has a List datatype, each element is treated separately.
If the datatype is generic, i.e. FILE or REFERENCE, values stay unchanged.
If the value is not a string, the value stays unchanged.
If the query using the datatype and the string value does not uniquely identify an Entity,
the value stays unchanged.
If an Entity is identified, then the string value is replaced by the ID.
"""
if get_list_datatype(prop.datatype) is None: # not a list
if (isinstance(prop.value, str) and is_reference(prop.datatype) and
prop.datatype != db.FILE and prop.datatype != db.REFERENCE): # datatype is a non-generic reference and value is a string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment