mirror of https://gitlab.com/pamhyr/pamhyr2
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
parent
707577521f
commit
63dfab6654
|
|
@ -31,7 +31,7 @@ from PyQt5.QtWidgets import (
|
|||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox,
|
||||
QComboBox, QMessageBox
|
||||
)
|
||||
|
||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||
|
|
@ -349,17 +349,32 @@ class InitialConditionTableModel(PamhyrTableModel):
|
|||
line_split[2],
|
||||
line_split[3]])
|
||||
|
||||
new_data = list(
|
||||
map(
|
||||
lambda d: self._lst.new_from_data(*d),
|
||||
data
|
||||
)
|
||||
new_data = []
|
||||
missing_rks = []
|
||||
for row in 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._undo.push(ReplaceDataCommand(self._lst, new_data))
|
||||
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):
|
||||
self._undo.undo()
|
||||
self.layoutChanged.emit()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,13 @@ class ICTranslate(MainTranslate):
|
|||
"InitialCondition", "Mage initial conditions file (*.INI *.ini)")
|
||||
self._dict["file_all"] = _translate(
|
||||
"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"] = {
|
||||
# "name": _translate("InitialCondition", "Name"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue