MAJOR: fundamental functions of the parser are ready and tested!

TO-DO:
1. follow the "TO-DO" comments to clean the code
2. filename should be NFFA-DI compliant like:
	nffa-di_NA01_Napoli_Na-26-015.h5
3. rheed data analysis should take two distinct functions
   one for the raw stream and one for the image
4. if time allows: consider moving most of main.py in separate modules
This commit is contained in:
2026-05-12 15:38:06 +02:00
parent df927b7c0e
commit 19a802694f
7 changed files with 76008 additions and 94 deletions

View File

@@ -85,6 +85,7 @@ class APIHandler:
"""
Downloads a specific attachment of a certain eLabFTW experiment (default) or item.
Only returns its binary data. Use method download_attachment_to_disk to save to file.
NOTE: Output is a dictionary where:
* The key is the attachment's filename;
* The value is the attachment's binary data.
@@ -100,7 +101,7 @@ class APIHandler:
)
config = elabapi.Configuration()
config.api_key["api_key"] = api_key
config.api_key["api_key"] = self.api_key
config.api_key_prefix["api_key"] = "Authorization"
config.host = self.elaburl
config.debug = False
@@ -132,7 +133,7 @@ class APIHandler:
"""
Downloads a specific attachment of a certain eLabFTW experiment (default) or item.
Downloads their binary data through method download_attachments_data and dumps it to dump_dir.
Returns nothing on success.
Returns full path of the output file.
Args:
elabid: eLabFTW internal ID of the selected resource.
@@ -151,9 +152,10 @@ class APIHandler:
uploads = self.download_attachment_data(elabid, upload_id, entryType=entryType)
for file in uploads:
raw_data = uploads[file]
with open(os.path.join(dump_dir, f"exp{elabid}-{file}"), "wb") as f:
full_path = os.path.join(dump_dir, f"exp{elabid}-{file}")
with open(full_path, "wb") as f:
f.write(raw_data)
return
return full_path
# Testing methods