From de2d12bd9915c037056b4884f3712309f989c3ce Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Wed, 15 Oct 2025 12:12:29 +0200 Subject: [PATCH] added file switch as single operation --- dap/accumulator.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dap/accumulator.py b/dap/accumulator.py index 36459b2..47a1651 100644 --- a/dap/accumulator.py +++ b/dap/accumulator.py @@ -52,8 +52,7 @@ def accumulate(_accumulator_host, accumulator_port): #TODO: accumulator_host is if run_name != run_name_before: run_name_before = run_name fname_output = f"{OUTPUT_DIR_NAME}/{detector}/{run_name}.dap" - output_dap.close() - output_dap.open(fname_output) + output_dap.switch(fname_output) res_is_good_frame = results.get("is_good_frame", -1) res_is_hit_frame = results.get("is_hit_frame", False) @@ -70,6 +69,10 @@ class FileHandler: def __init__(self): self.file = None + def switch(self, fname): + self.close() + self.open(fname) + def open(self, fname): dname = os.path.dirname(fname) os.makedirs(dname, exist_ok=True)