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

ENH: allow wildcard is_referenced_by

parent 9361573b
No related branches found
No related tags found
2 merge requests!160STY: styling,!146ENH: allow wildcard is_referenced_by
Pipeline #46655 canceled
......@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ###
* 'transform' sections can be added to a CFood to apply functions to values stored in variables.
* default transform functions: submatch, split and replace.
* `*` can now be used as a wildcard in the identifiables parameter file to denote
that any Record may reference the identified one.
### Changed ###
- If the `parents` key is used in a cfood at a lower level for a Record that
......
......@@ -219,18 +219,23 @@ identifiabel, identifiable and identified record) for a Record.
# separate class too
if prop.name.lower() == "is_referenced_by":
for givenrt in prop.value:
rt_and_children = get_children_of_rt(givenrt)
found = False
for rtname in rt_and_children:
if (id(record) in referencing_entities
and rtname in referencing_entities[id(record)]):
identifiable_backrefs.extend(
referencing_entities[id(record)][rtname])
if givenrt == "*":
for rt, rec in referencing_entities[id(record)].items():
identifiable_backrefs.extend(rec)
found = True
else:
rt_and_children = get_children_of_rt(givenrt)
for rtname in rt_and_children:
if (id(record) in referencing_entities
and (rtname in referencing_entities[id(record)])):
identifiable_backrefs.extend(
referencing_entities[id(record)][rtname])
found = True
if not found:
# TODO: is this the appropriate error?
raise NotImplementedError(
f"The following record is missing an identifying property:"
f"The following record is missing an identifying property:\n"
f"RECORD\n{record}\nIdentifying PROPERTY\n{prop.name}"
)
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment