From e194715445f8165aa581718ebd322bdad7020037 Mon Sep 17 00:00:00 2001 From: danielhrisca Date: Wed, 6 Sep 2023 13:20:55 +0300 Subject: [PATCH] update .lab file import and export --- src/asammdf/blocks/utils.py | 12 +++++++++++- src/asammdf/gui/widgets/batch.py | 10 ++++++++++ src/asammdf/gui/widgets/file.py | 16 +++++++++++++++- src/asammdf/version.py | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/asammdf/blocks/utils.py b/src/asammdf/blocks/utils.py index 5baca0a70..752aef624 100644 --- a/src/asammdf/blocks/utils.py +++ b/src/asammdf/blocks/utils.py @@ -2420,6 +2420,11 @@ def load_channel_names_from_file(file_name, lab_section=""): channels = info[lab_section] else: channels = list(info.values())[0] + + channels = [ + name.split(';')[0] + for name in channels + ] elif extension == ".cfg": with open(file_name, "r") as infile: @@ -2455,7 +2460,12 @@ def load_lab(file): if "s" in locals(): s.append(line) - return {name: channels for name, channels in sections.items() if channels} + return { + name: channels + for name, channels in sections.items() + if channels + if name != "SETTINGS" + } class SignalFlags(IntFlag): diff --git a/src/asammdf/gui/widgets/batch.py b/src/asammdf/gui/widgets/batch.py index e6d0fcb20..65f232525 100644 --- a/src/asammdf/gui/widgets/batch.py +++ b/src/asammdf/gui/widgets/batch.py @@ -1853,6 +1853,11 @@ def save_filter_list(self): with open(file_name, "w") as output: if suffix == ".lab": + output.write("""[SETTINGS] +Version;V1.1 +MultiRasterSeparator;& + +""") output.write(f"[{section_name}]\n") output.write("\n".join(natsorted(signals))) @@ -1895,6 +1900,11 @@ def load_filter_list(self, event=None, file_name=None): return else: channels = list(info.values())[0] + + channels = [ + name.split(';')[0] + for name in channels + ] else: channels = load_channel_names_from_file(file_name) diff --git a/src/asammdf/gui/widgets/file.py b/src/asammdf/gui/widgets/file.py index 87b51616a..8d4af2328 100644 --- a/src/asammdf/gui/widgets/file.py +++ b/src/asammdf/gui/widgets/file.py @@ -1094,7 +1094,11 @@ def load_channel_list(self, event=None, file_name=None, manually=False): ) if not ok: return - channels = info[section] + + channels = [ + name.split(';')[0] + for name in info[section] + ] elif extension in (".cfg", ".txt"): with open(file_name, "r") as infile: @@ -1387,6 +1391,11 @@ def save_filter_list(self): with open(file_name, "w") as output: if suffix == ".lab": + output.write("""[SETTINGS] +Version;V1.1 +MultiRasterSeparator;& + +""") output.write(f"[{section_name}]\n") output.write("\n".join(natsorted(signals))) @@ -1430,6 +1439,11 @@ def load_filter_list(self, event=None, file_name=None): return else: channels = list(info.values())[0] + + channels = [ + name.split(';')[0] + for name in channels + ] else: channels = load_channel_names_from_file(file_name) diff --git a/src/asammdf/version.py b/src/asammdf/version.py index 0034dfb1a..18b92c930 100644 --- a/src/asammdf/version.py +++ b/src/asammdf/version.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- """ asammdf version module """ -__version__ = "7.3.15.dev4" +__version__ = "7.3.15.dev5"