fixes category title for materials: "Substrate", not "Substrate batch"

"Substrate" is the title of the category of substrate items
"Substrate batch" is a key in a sample's dictionary
This commit is contained in:
2026-02-12 15:16:35 +01:00
parent 5a605038df
commit 820337c06e

View File

@@ -23,13 +23,14 @@ def call_material_from_elabid(elabid):
''' '''
Calls a material from eLabFTW using its elabid, then returns an object of the Material class. Calls a material from eLabFTW using its elabid, then returns an object of the Material class.
If the entry is neither a PLD Target or a Substrate batch returns ValueError. Such entries always have a category_title key with its value either being "PLD Target" or "Substrate batch". If the entry is neither a PLD Target or a Substrate batch returns ValueError. Such entries always have a category_title key with its value matching exactly "PLD Target" or "Substrate".
Because of an old typo, the value "Subtrate batch" (second 's' is missing) is also accepted. Because of an old typo, the value "Subtrate" (second 's' is missing) is also accepted.
''' '''
try: try:
material_data = APIHandler(apikey).get_entry_from_elabid(elabid, entryType="items") material_data = APIHandler(apikey).get_entry_from_elabid(elabid, entryType="items")
# TO-DO: correct this typo on elabftw: Subtrate → Substrate. # TO-DO: correct this typo on elabftw: Subtrate → Substrate.
if not material_data.get("category_title") in ["PLD Target", "Substrate batch", "Subtrate batch"]: if not material_data.get("category_title") in ["PLD Target", "Substrate", "Subtrate"]:
print(f"Category of the resource: {material_data.get("category_title")}.")
raise ValueError(f"The referenced resource (elabid = {elabid}) is not a material.") raise ValueError(f"The referenced resource (elabid = {elabid}) is not a material.")
material_object = Material(material_data) material_object = Material(material_data)
except ConnectionError as e: except ConnectionError as e: