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:
2026-05-13 12:12:32 +02:00
parent 2eea3fc2dd
commit 686f869d10
3 changed files with 182 additions and 40 deletions

View File

@@ -11,19 +11,19 @@ class APIHandler:
(since the API doesn't support downloading attachments AFAIK).
Args:
api_key: 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.
ELABFTW_API_URL: Complete URL of the eLabFTW instance's root for the API endpoints.
In full caps because it won't (shouldn't) be changed much.
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.
ELABFTW_API_URL: str: Complete URL of the eLabFTW instance's root for the API endpoints.
In full caps because it won't (shouldn't) be changed much.
"""
# TO-DO: remove static url.
def __init__(
self, api_key="", ELABFTW_API_URL="https://elabftw.fisica.unina.it/api/v2"
):
"""Init method, apikey suggested but not required (empty by default)."""
"""Init method, api_key suggested but not required (empty by default)."""
self.api_key = api_key
self.auth = {"Authorization": api_key}
self.content = {"Content-Type": "application/json"}
@@ -34,9 +34,9 @@ class APIHandler:
"""
Returns raw data (as dictionary) from its elabid and entry type.
args:
elabid: elabftw internal id of the selected resource.
entryType: Resource type. Anything other than "experiments" or "items" WILL raise an error.
Args:
elabid: int: elabftw internal id of the selected resource.
entryType: str: Resource type. Anything other than "experiments" or "items" WILL raise an error.
"""
if entryType not in ["experiments", "items"]:
raise Exception(
@@ -91,9 +91,9 @@ class APIHandler:
* The value is the attachment's binary data.
Args:
elabid: eLabFTW internal ID of the selected resource.
upload_id: eLabFTW internal ID of the selected upload.
entryType: Resource type. Anything other than "experiments" or "items" WILL raise an error.
elabid: int: eLabFTW internal ID of the selected resource.
upload_id: int: eLabFTW internal ID of the selected upload.
entryType: str: Resource type. Anything other than "experiments" or "items" WILL raise an error.
"""
if entryType not in ["experiments", "items"]:
raise Exception(
@@ -136,12 +136,12 @@ class APIHandler:
Returns full path of the output file.
Args:
elabid: eLabFTW internal ID of the selected resource.
upload_id: eLabFTW internal ID of the selected upload.
entryType: Resource type. Anything other than "experiments" or "items" WILL raise an error.
dump_dir: Directory to which to save the attachments. Default is "output/attachments".
persistent: [Unused] Decides if the files will stay on disk after all operations are completed.
If set to False, deletes the file upon exiting.
elabid: int: eLabFTW internal ID of the selected resource.
upload_id: int: eLabFTW internal ID of the selected upload.
entryType: str: Resource type. Anything other than "experiments" or "items" WILL raise an error.
dump_dir: str: Directory to which to save the attachments. Default is "output/attachments".
persistent: bool: [Unused] Decides if the files will stay on disk after all operations are completed.
If set to False, deletes the file upon exiting. Default = True.
"""
if entryType not in ["experiments", "items"]: