Skip to content

Commit

Permalink
update .lab file import and export
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Sep 6, 2023
1 parent b1177e1 commit e194715
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/asammdf/blocks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
10 changes: 10 additions & 0 deletions src/asammdf/gui/widgets/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 15 additions & 1 deletion src/asammdf/gui/widgets/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)))

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/asammdf/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
""" asammdf version module """

__version__ = "7.3.15.dev4"
__version__ = "7.3.15.dev5"

0 comments on commit e194715

Please sign in to comment.