From 5aa7527cca949e56d99e1724754a2acb5c9cfab9dd08a69fb3b58e1619a74f37 Mon Sep 17 00:00:00 2001 From: PioApocalypse Date: Tue, 10 Feb 2026 14:46:57 +0100 Subject: [PATCH] more use(less,ful) comments --- src/classes.py | 8 ++++---- src/functions.py | 3 +++ src/main.py | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/classes.py b/src/classes.py index 8514d92..c0d23bb 100644 --- a/src/classes.py +++ b/src/classes.py @@ -83,10 +83,10 @@ class Entrypoint: def __init__(self, sample_data): try: self.extra = sample_data["metadata_decoded"]["extra_fields"] - self.linked_items = sample_data["items_links"] - self.batch_elabid = self.extra["Substrate batch"]["value"] - self.linked_experiments = sample_data["related_experiments_links"] - self.linked_experiments_elabid = [ i["entityid"] for i in self.linked_experiments ] + self.linked_items = sample_data["items_links"] # dict + self.batch_elabid = self.extra["Substrate batch"]["value"] # elabid + self.linked_experiments = sample_data["related_experiments_links"] # dict + self.linked_experiments_elabid = [ i["entityid"] for i in self.linked_experiments ] # list of elabid except KeyError as k: # Some keys are not required and can be called through the .get() method - which is permissive and allows null values; # Other keys are required so if they can't be called (invalid or null) raise error and stop execution of the program: diff --git a/src/functions.py b/src/functions.py index e4133eb..ab48f35 100644 --- a/src/functions.py +++ b/src/functions.py @@ -1,3 +1,6 @@ +""" +Currently unused! +""" import json, requests from APIHandler import APIHandler diff --git a/src/main.py b/src/main.py index c854d7a..8846b38 100644 --- a/src/main.py +++ b/src/main.py @@ -44,6 +44,8 @@ if __name__=="__main__": elif data.get("category_title") in ["PLD Target", "Substrate"]: item = Material(data) print(item.get_compound_formula(apikey)) + else: + raise Exception("The selected item or experiment is not in one of the following categories: [Sample, PLD Target, Substrate, PLD Deposition].") result = item.__dict__ result.pop("extra") print(result) \ No newline at end of file