documents all the functions/classes/methods (by hand)
no AI used, it took more than I'm willing to admit but it's done
This commit is contained in:
110
src/classes.py
110
src/classes.py
@@ -15,6 +15,10 @@ class Layer:
|
||||
"""
|
||||
|
||||
def __init__(self, layer_data):
|
||||
"""
|
||||
Properties/Attributes:
|
||||
Too many to list.
|
||||
"""
|
||||
try:
|
||||
self.elabid = layer_data["id"]
|
||||
self.operator = layer_data["fullname"]
|
||||
@@ -131,6 +135,20 @@ class Layer:
|
||||
self.description = layer_data.get("body") or None
|
||||
|
||||
def get_instruments(self, api_key):
|
||||
"""
|
||||
Retruns a dictionary of all the instruments used to create the layer.
|
||||
The format of the dictionary is:
|
||||
{
|
||||
"laser_system": str,
|
||||
"deposition_chamber": str,
|
||||
"rheed_system": str
|
||||
}
|
||||
|
||||
Arg: api_key: str: A valid API key for the eLabFTW instance where the data is stored, with permissions to access the relevant entries.
|
||||
eLabFTW's API keys are well documented here: https://doc.elabftw.net/docs/usage/api/.
|
||||
If you don't have an API key and are uncapable of creating one, contact your eLabFTW administrator.
|
||||
Or RTFM and create one yourself, it's not that hard.
|
||||
"""
|
||||
raw_lasersys_data = APIHandler(api_key).get_entry_from_elabid(
|
||||
self.laser_system_elabid, entryType="items"
|
||||
)
|
||||
@@ -220,6 +238,15 @@ class Entrypoint:
|
||||
"""
|
||||
|
||||
def __init__(self, sample_data):
|
||||
"""
|
||||
Properties/Attributes:
|
||||
* name: str: Name of the sample. Fairly important, and always present unless someone screws up REALLY bad.
|
||||
* linked_items: dict: Dictionary generated by eLabFTW containing metadata on the items linked to the entrypoint.
|
||||
* batch_elabid: int: eLabFTW internal id of the batch of the substrate used as the foundation of the sample.
|
||||
* proposal: int: eLabFTW internal id of the proposal linked to the sample.
|
||||
* linked_experiments: dict: Dictionary generated by eLabFTW containing metadata on the experiments linked to the entrypoint.
|
||||
* linked_experiments_elabid: list: List of eLabFTW internal id's of the experiments linked to the entrypoint.
|
||||
"""
|
||||
try:
|
||||
self.extra = sample_data["metadata_decoded"]["extra_fields"]
|
||||
self.linked_items = sample_data["items_links"] # dict
|
||||
@@ -239,6 +266,7 @@ class Entrypoint:
|
||||
self.name = (
|
||||
sample_data.get("title") or None
|
||||
) # error prevention is more important than preventing empty fields here
|
||||
# although I don't think it's even possible to fuck up this bad...
|
||||
|
||||
|
||||
class Material:
|
||||
@@ -254,6 +282,14 @@ class Material:
|
||||
"""
|
||||
|
||||
def __init__(self, material_data):
|
||||
"""
|
||||
Properties/Attributes:
|
||||
* name: str: Name of the material.
|
||||
* compound_elabid: int: eLabFTW internal id of the compound.
|
||||
* dimensions: str: Dimensions of the material, in standard format.
|
||||
The class recognizes the unit of measurement and acts consequently.
|
||||
* dimensions_unit: str: Unit of measurement - either "mm x mm", "inches" or None.
|
||||
"""
|
||||
try:
|
||||
self.name = material_data["title"] # required
|
||||
self.extra = material_data["metadata_decoded"]["extra_fields"]
|
||||
@@ -275,6 +311,20 @@ class Material:
|
||||
)
|
||||
|
||||
def get_compound_data(self, apikey):
|
||||
"""
|
||||
Returns a dictionary with the relevant data on the compound of which the material is made.
|
||||
The format of the dictionary is:
|
||||
{
|
||||
"name": str,
|
||||
"chemical_formula": str,
|
||||
"cas_number": str
|
||||
}
|
||||
|
||||
Arg: api_key: str: A valid API key for the eLabFTW instance where the data is stored, with permissions to access the relevant entries.
|
||||
eLabFTW's API keys are well documented here: https://doc.elabftw.net/docs/usage/api/.
|
||||
If you don't have an API key and are uncapable of creating one, contact your eLabFTW administrator.
|
||||
Or RTFM and create one yourself, it's not that hard.
|
||||
"""
|
||||
raw_compound_data = APIHandler(apikey).get_entry_from_elabid(
|
||||
self.compound_elabid, entryType="items"
|
||||
)
|
||||
@@ -295,7 +345,32 @@ class Material:
|
||||
|
||||
|
||||
class Substrate(Material):
|
||||
"""
|
||||
Substrate(material_data) - where material_data is a Python dictionary.
|
||||
|
||||
Inherits from Material and it's meant to be used exclusively for eLabFTW Resources of the "Substrate" category.
|
||||
"""
|
||||
|
||||
def __init__(self, material_data):
|
||||
"""
|
||||
Properties/Attributes common to all Materials:
|
||||
* name: str: Name of the material.
|
||||
* compound_elabid: int: eLabFTW internal id of the compound.
|
||||
* dimensions: str: Dimensions of the material, in standard format.
|
||||
The class recognizes the unit of measurement and acts consequently.
|
||||
* dimensions_unit: str: Unit of measurement - either "mm x mm", "inches" or None.
|
||||
|
||||
Specific properties/attributes:
|
||||
* orientation: str:
|
||||
* miscut_angle: str:
|
||||
* miscut_angle_unit: str:
|
||||
* miscut_direction: str:
|
||||
* thickness: str:
|
||||
* thickness_unit: str:
|
||||
* surface_treatment: str:
|
||||
* manufacturer: str:
|
||||
* batch_id: str:
|
||||
"""
|
||||
super().__init__(material_data)
|
||||
try:
|
||||
self.orientation = self.extra["Orientation"]["value"]
|
||||
@@ -315,7 +390,28 @@ class Substrate(Material):
|
||||
|
||||
|
||||
class Target(Material):
|
||||
"""
|
||||
Target(material_data) - where material_data is a Python dictionary.
|
||||
|
||||
Inherits from Material and it's meant to be used exclusively for eLabFTW Resources of the "PLD Target" category.
|
||||
"""
|
||||
|
||||
def __init__(self, material_data):
|
||||
"""
|
||||
Properties/Attributes common to all Materials:
|
||||
* name: str: Name of the material.
|
||||
* compound_elabid: int: eLabFTW internal id of the compound.
|
||||
* dimensions: str: Dimensions of the material, in standard format.
|
||||
The class recognizes the unit of measurement and acts consequently.
|
||||
* dimensions_unit: str: Unit of measurement - either "mm x mm", "inches" or None.
|
||||
|
||||
Specific properties/attributes:
|
||||
* thickness: str:
|
||||
* thickness_unit: str:
|
||||
* shape: str:
|
||||
* solid_form: str:
|
||||
* manufacturer: str:
|
||||
"""
|
||||
super().__init__(material_data)
|
||||
try:
|
||||
self.thickness = self.extra["Thickness"]["value"]
|
||||
@@ -332,7 +428,21 @@ class Target(Material):
|
||||
|
||||
|
||||
class Proposal:
|
||||
"""
|
||||
Proposal(proposal_data) - where proposal_data is a Python dictionary.
|
||||
|
||||
Recovers only the relevant info on a proposal linked to the entrypoint sample.
|
||||
Which currently is just its name.
|
||||
|
||||
If the name starts with "Proposal " (space included) that gets omitted from the output.
|
||||
"""
|
||||
|
||||
def __init__(self, proposal_data):
|
||||
"""
|
||||
Properties/Attributes:
|
||||
* name: str: Name of the proposal.
|
||||
If the name starts with "Proposal " (space included) that gets omitted from the output.
|
||||
"""
|
||||
if "Proposal " in proposal_data["title"]:
|
||||
self.name = proposal_data["title"].replace("Proposal ", "")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user