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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user