From 6f1a84af104abdeb430c263dd157a99599eef6d1 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 3 Apr 2024 17:26:37 +0200 Subject: [PATCH 1/3] cancel ascii reading only if skip is True --- src/gui_qt/io/filereaders.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui_qt/io/filereaders.py b/src/gui_qt/io/filereaders.py index 808d96f..d1428fc 100755 --- a/src/gui_qt/io/filereaders.py +++ b/src/gui_qt/io/filereaders.py @@ -51,7 +51,9 @@ class QFileReader(QtCore.QObject): if not isinstance(fname, list): fname = [fname] + status = QtWidgets.QDialog.Accepted for f in fname: + print(f) f = Path(f) dtype = self.guess_type(f) if dtype in self.reader: @@ -60,10 +62,13 @@ class QFileReader(QtCore.QObject): raise ValueError(f'Unknown type for file {f}') try: + print(status, QtWidgets.QDialog.DialogCode.Accepted) + print(r) + print(repr(self.reader['txt'].skip)) # If QAsciiReader.skip = True it accepts automatically and returns None - status = r(f).exec() - if status == QtWidgets.QDialog.Rejected and isinstance(r, QAsciiReader): + if status == QtWidgets.QDialog.DialogCode.Rejected and isinstance(r, QAsciiReader) and self.reader['txt'].skip: break + status = r(f).exec() except AttributeError: pass -- 2.39.5 From 3c283ddac9f8aa513bcdc161556a4a88f23a477c Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 3 Apr 2024 17:51:43 +0200 Subject: [PATCH 2/3] split header line like data line in asciireader --- src/gui_qt/io/asciireader.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui_qt/io/asciireader.py b/src/gui_qt/io/asciireader.py index 489c33d..ea4c980 100644 --- a/src/gui_qt/io/asciireader.py +++ b/src/gui_qt/io/asciireader.py @@ -132,7 +132,10 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader): self.ascii_table.setHorizontalHeaderLabels(map(str, range(1, self.ascii_table.columnCount() + 1))) if self.column_checkBox.isChecked() and self.line_spinBox.isEnabled(): header_line = self.reader.header[self.line_spinBox.value()-1] - self.ascii_table.setHorizontalHeaderLabels(header_line.split()) + header_line = header_line.strip('\n\t\r, ') + header_line = re.sub(r'[\t ;,]+', ';', header_line) + + self.ascii_table.setHorizontalHeaderLabels(header_line.split(';')) @QtCore.pyqtSlot(int, name='on_staggered_checkBox_stateChanged') def changestaggeredrange(self, state: int): -- 2.39.5 From 5b4753476cfabb4ae53f4bd4580d0e6feafb8a67 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 3 Apr 2024 17:52:51 +0200 Subject: [PATCH 3/3] remove print --- src/gui_qt/io/filereaders.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui_qt/io/filereaders.py b/src/gui_qt/io/filereaders.py index d1428fc..59b491a 100755 --- a/src/gui_qt/io/filereaders.py +++ b/src/gui_qt/io/filereaders.py @@ -53,7 +53,6 @@ class QFileReader(QtCore.QObject): status = QtWidgets.QDialog.Accepted for f in fname: - print(f) f = Path(f) dtype = self.guess_type(f) if dtype in self.reader: @@ -62,9 +61,6 @@ class QFileReader(QtCore.QObject): raise ValueError(f'Unknown type for file {f}') try: - print(status, QtWidgets.QDialog.DialogCode.Accepted) - print(r) - print(repr(self.reader['txt'].skip)) # If QAsciiReader.skip = True it accepts automatically and returns None if status == QtWidgets.QDialog.DialogCode.Rejected and isinstance(r, QAsciiReader) and self.reader['txt'].skip: break -- 2.39.5