Import INI files: non-blocking error if no profile associated with the RK is found in INI file, notifies the user of the relevant RK

new_design_pol
JeaDylan 2026-08-27 18:49:22 +02:00
parent 707577521f
commit 63dfab6654
2 changed files with 29 additions and 7 deletions

View File

@ -31,7 +31,7 @@ from PyQt5.QtWidgets import (
QDialogButtonBox, QPushButton, QLineEdit, QDialogButtonBox, QPushButton, QLineEdit,
QFileDialog, QTableView, QAbstractItemView, QFileDialog, QTableView, QAbstractItemView,
QUndoStack, QShortcut, QAction, QItemDelegate, QUndoStack, QShortcut, QAction, QItemDelegate,
QComboBox, QComboBox, QMessageBox
) )
from View.Tools.PamhyrTable import PamhyrTableModel from View.Tools.PamhyrTable import PamhyrTableModel
@ -349,17 +349,32 @@ class InitialConditionTableModel(PamhyrTableModel):
line_split[2], line_split[2],
line_split[3]]) line_split[3]])
new_data = list( new_data = []
map( missing_rks = []
lambda d: self._lst.new_from_data(*d), for row in data:
data rk = row[0].strip()
) try:
) new_data.append(self._lst.new_from_data(*row))
except ValueError:
missing_rks.append(rk)
logger.warning(
f"No profile found for imported RK {rk} "
f"in reach {self._reach.name}"
)
self.layoutAboutToBeChanged.emit() self.layoutAboutToBeChanged.emit()
self._undo.push(ReplaceDataCommand(self._lst, new_data)) self._undo.push(ReplaceDataCommand(self._lst, new_data))
self.layoutChanged.emit() self.layoutChanged.emit()
if missing_rks:
QMessageBox.warning(
self._table_view,
self._trad["missing_rk_title"],
self._trad["missing_rk_text"].format(
rks=", ".join(missing_rks)
)
)
def undo(self): def undo(self):
self._undo.undo() self._undo.undo()
self.layoutChanged.emit() self.layoutChanged.emit()

View File

@ -42,6 +42,13 @@ class ICTranslate(MainTranslate):
"InitialCondition", "Mage initial conditions file (*.INI *.ini)") "InitialCondition", "Mage initial conditions file (*.INI *.ini)")
self._dict["file_all"] = _translate( self._dict["file_all"] = _translate(
"InitialCondition", "All files (*)") "InitialCondition", "All files (*)")
self._dict["missing_rk_title"] = _translate(
"InitialCondition", "Profiles not found")
self._dict["missing_rk_text"] = _translate(
"InitialCondition",
"No profile was found for the following RK values: {rks}. "
"They were not imported and must be entered manually."
)
self._sub_dict["table_headers"] = { self._sub_dict["table_headers"] = {
# "name": _translate("InitialCondition", "Name"), # "name": _translate("InitialCondition", "Name"),