From 820337c06e4c8efc4acba522a46d05affcded7aaff27eb2ccb11065ca2311157 Mon Sep 17 00:00:00 2001 From: PioApocalypse Date: Thu, 12 Feb 2026 15:16:35 +0100 Subject: [PATCH] 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 --- src/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index fcab2d1..f8c4a2f 100644 --- a/src/main.py +++ b/src/main.py @@ -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. - 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". - Because of an old typo, the value "Subtrate batch" (second 's' is missing) is also accepted. + 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" (second 's' is missing) is also accepted. ''' try: material_data = APIHandler(apikey).get_entry_from_elabid(elabid, entryType="items") # 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.") material_object = Material(material_data) except ConnectionError as e: