cancel ascii reading only if skip is True

This commit is contained in:
Dominik Demuth 2024-04-03 17:26:37 +02:00
parent b25db92cf1
commit 6f1a84af10

View File

@ -51,7 +51,9 @@ class QFileReader(QtCore.QObject):
if not isinstance(fname, list): if not isinstance(fname, list):
fname = [fname] fname = [fname]
status = QtWidgets.QDialog.Accepted
for f in fname: for f in fname:
print(f)
f = Path(f) f = Path(f)
dtype = self.guess_type(f) dtype = self.guess_type(f)
if dtype in self.reader: if dtype in self.reader:
@ -60,10 +62,13 @@ class QFileReader(QtCore.QObject):
raise ValueError(f'Unknown type for file {f}') raise ValueError(f'Unknown type for file {f}')
try: 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 QAsciiReader.skip = True it accepts automatically and returns None
status = r(f).exec() if status == QtWidgets.QDialog.DialogCode.Rejected and isinstance(r, QAsciiReader) and self.reader['txt'].skip:
if status == QtWidgets.QDialog.Rejected and isinstance(r, QAsciiReader):
break break
status = r(f).exec()
except AttributeError: except AttributeError:
pass pass