Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/implementors/imageviewer/export.py: 100%
17 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import os
4import json
5import datetime
7from daiquiri.core.components import ComponentActor
10class ExportActor(ComponentActor):
11 name = "export"
12 saving_args = {"data_filename": "export_{time}"}
14 def method(self, **kwargs):
15 for subsample in self["subsamples"]:
16 motors = {}
17 for _, details in subsample["motors"].items():
18 for motor_name, position in details.items():
19 motors[motor_name] = position["destination"]
20 motors.update(subsample["additional"])
22 file = os.path.join(self["dirname"], f"{subsample['subsampleid']}.json")
23 with open(file, "w") as jf:
24 jf.write(
25 json.dumps(
26 {
27 "subsampleid": subsample["subsampleid"],
28 "type": subsample["type"],
29 "timestamp": str(datetime.datetime.now()),
30 "comments": subsample["comments"],
31 "extrametadata": subsample["extrametadata"],
32 "motors": motors,
33 },
34 indent=4,
35 )
36 )