integrates sub-classes Target and Substrate in main.py
This commit is contained in:
19
src/main.py
19
src/main.py
@@ -28,11 +28,15 @@ def call_material_from_elabid(elabid):
|
|||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
material_data = APIHandler(apikey).get_entry_from_elabid(elabid, entryType="items")
|
material_data = APIHandler(apikey).get_entry_from_elabid(elabid, entryType="items")
|
||||||
|
material_category = material_data.get("category_title")
|
||||||
# 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", "Subtrate"]:
|
if not material_category in ["PLD Target", "Substrate", "Subtrate"]:
|
||||||
print(f"Category of the resource: {material_data.get("category_title")}.")
|
print(f"Category of the resource: {material_category}.")
|
||||||
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)
|
elif material_category == "PLD Target":
|
||||||
|
material_object = Target(material_data)
|
||||||
|
else:
|
||||||
|
material_object = Substrate(material_data)
|
||||||
except ConnectionError as e:
|
except ConnectionError as e:
|
||||||
raise ConnectionError(e)
|
raise ConnectionError(e)
|
||||||
return material_object # Material-class object
|
return material_object # Material-class object
|
||||||
@@ -106,16 +110,21 @@ if __name__=="__main__":
|
|||||||
data = APIHandler(apikey).get_entry_from_elabid(elabid)
|
data = APIHandler(apikey).get_entry_from_elabid(elabid)
|
||||||
sample = Entrypoint(data)
|
sample = Entrypoint(data)
|
||||||
batch = chain_entrypoint_to_batch(sample) # Material-class object
|
batch = chain_entrypoint_to_batch(sample) # Material-class object
|
||||||
|
bd = batch.__dict__
|
||||||
|
bd.pop("extra")
|
||||||
layers = chain_entrypoint_to_layers(sample) # list of Layer-class objects
|
layers = chain_entrypoint_to_layers(sample) # list of Layer-class objects
|
||||||
print(f"Sample name:\n{sample.name}\n")
|
print(f"Sample name:\n{sample.name}\n")
|
||||||
print(f"Substrate data:\n{batch.get_compound_formula(apikey)}\n")
|
print(f"Substrate data:\n{bd}\n")
|
||||||
print(f"Layers data:")
|
print(f"Layers data:")
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
ld = layer.__dict__
|
ld = layer.__dict__
|
||||||
ld.pop("extra")
|
ld.pop("extra")
|
||||||
tgt = chain_layer_to_target(layer)
|
tgt = chain_layer_to_target(layer)
|
||||||
|
td = tgt.__dict__
|
||||||
|
td.pop("extra")
|
||||||
print(ld)
|
print(ld)
|
||||||
print(tgt.get_compound_formula(apikey) + f"\n")
|
print(td)
|
||||||
|
print()
|
||||||
|
|
||||||
# entryType = None
|
# entryType = None
|
||||||
# while entryType not in ["items", "experiments"]:
|
# while entryType not in ["items", "experiments"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user