Skip to content
Snippets Groups Projects
Commit 67b31746 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

ENH: Make PI column name configurable

parent b484c52e
Branches
Tags
1 merge request!1F awi sams
...@@ -194,13 +194,13 @@ def main(): ...@@ -194,13 +194,13 @@ def main():
child.get_property(custom_label_prop.id).value = row[get_column_header_name("custom_label_prop")] child.get_property(custom_label_prop.id).value = row[get_column_header_name("custom_label_prop")]
# Treat PI # Treat PI
if _value_in_row("PI", row): if _value_in_row(get_column_header_name("PI"), row):
pi = row["PI"] pi = row[get_column_header_name("PI")]
pi_prop = cached_get_entity_by(query="FIND PROPERTY Pi") pi_prop = cached_get_entity_by(query=f"FIND PROPERTY {get_entity_name{'PI'}")
try: try:
query = f"FIND RECORD Person WITH ID={int(pi)}" query = f"FIND RECORD Person WITH ID={int(pi)}"
except ValueError: except ValueError:
query = f"FIND RECORD Person WITH AN Abbreviation='{pi}'" query = f"FIND RECORD Person WITH AN '{get_entity_name('abbreviation_prop')}'='{pi}'"
try: try:
pi_rec = cached_get_entity_by(query=query) pi_rec = cached_get_entity_by(query=query)
if child.get_property(pi_prop.name) is not None: if child.get_property(pi_prop.name) is not None:
...@@ -208,7 +208,7 @@ def main(): ...@@ -208,7 +208,7 @@ def main():
else: else:
child.add_property(id=pi_prop.id, name=pi_prop.name, value=pi_rec.id) child.add_property(id=pi_prop.id, name=pi_prop.name, value=pi_rec.id)
except db.EmptyUniqueQueryError: except db.EmptyUniqueQueryError:
logger.warning(f"There is no PI with BIS ID or abbreviation {pi}. Skipping.") logger.warning(f"There is no PI with ID or {get_entity_name('abbreviation_prop')} {pi}. Skipping.")
# Collection(s) # Collection(s)
if _value_in_row("Collection", row): if _value_in_row("Collection", row):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment