From b259580736a399ec75aceaaf0d0d350c3cbc3c43 Mon Sep 17 00:00:00 2001 From: Casper Date: Mon, 24 Oct 2022 12:05:59 +0200 Subject: [PATCH] Add: DaqConfigurations.loadRaw() and saveRaw() for easy accessing of DAQ configuration data --- src/lasp/lasp_daqconfigs.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lasp/lasp_daqconfigs.py b/src/lasp/lasp_daqconfigs.py index fe80f4f..c7bf381 100644 --- a/src/lasp/lasp_daqconfigs.py +++ b/src/lasp/lasp_daqconfigs.py @@ -29,7 +29,7 @@ class DaqConfigurations: output_config: DaqConfiguration, ): """ - Initialize set of DaqConfigurations. + Initialize set of DaqConfigurations. Args: duplex_mode: If true, the input configuration is used for output as @@ -92,6 +92,18 @@ class DaqConfigurations: output_config = DaqConfiguration.fromTOML(config_str[2]) return DaqConfigurations(duplex_mode, input_config, output_config) + @staticmethod + def loadRaw(): + """ + Returns configurations presets in the raw form they are stored. + + Returns: + all configurations, raw + """ + with lasp_shelve() as sh: + configs_raw = sh.load(f"daqconfigs_v{LASP_VERSION_MAJOR}", {}) + return configs_raw + def save(self, name: str): """ Save the current set of configurations to the shelve store. @@ -109,6 +121,17 @@ class DaqConfigurations: configs_str[name] = [self.duplex_mode, input_str, output_str] sh.store(f"daqconfigs_v{LASP_VERSION_MAJOR}", configs_str) + @staticmethod + def saveRaw(configs_raw): + """ + Save configurations presets, using already formatted data + + Arg: + all configurations, raw data format in form they are stored + """ + with lasp_shelve() as sh: + sh.store(f"daqconfigs_v{LASP_VERSION_MAJOR}", configs_raw) + @staticmethod def delete(name: str): """