Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhroom committed Nov 12, 2024
1 parent 871ea62 commit dfd916f
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions rascal2/widgets/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def create_project_view(self) -> None:
absorption_label = QtWidgets.QLabel("Absorption:", self, objectName="boldlabel")
self.absorption_checkbox = QtWidgets.QCheckBox()
# this is how you make a checkbox read-only but still checkable from inside code...
self.absorption_checkbox.setAttribute(QtCore.Qt.WidgetAttribute.WA_TransparentForMouseEvents)
self.absorption_checkbox.setDisabled(True)

settings_layout.addWidget(absorption_label)
settings_layout.addWidget(self.absorption_checkbox)
Expand Down Expand Up @@ -304,23 +304,25 @@ def validate_draft_project(self):
layer_attrs.remove("name")
layer_attrs.remove("hydrate_with")
# ensure all layer parameters have been filled in, and all names are layers that exist
valid_params = [p.name for p in self.draft_project["parameters"]]
for i, layer in enumerate(self.draft_project["layers"]):
missing_params = [p for p in layer_attrs if getattr(layer, p) == ""]
invalid_params = [
(p, v)
for p in layer_attrs
if (v := getattr(layer, p)) not in [p.name for p in self.draft_project["parameters"]]
and p not in missing_params
]
missing_params = []
invalid_params = []
for attr in layer_attrs:
param = getattr(layer, attr)
if param == "":
missing_params.append(attr)
elif param not in valid_params:
invalid_params.append((attr, param))

if missing_params:
noun = "a parameter" if len(missing_params) == 1 else "parameters"
msg = f"Layer '{layer.name}' (row {i+1}) is missing {noun}: {', '.join(missing_params)}"
errors.append(msg)
if invalid_params:
noun = "an invalid value" if len(invalid_params) == 1 else "invalid values"
msg = (
f"Layer '{layer.name}' (row {i+1}) has {noun}: "
f"{', '.join(f'"{v}" for parameter {p}' for p, v in invalid_params)}"
msg = f"Layer '{layer.name}' (row {i+1}) has {noun}: " "{0}".format(
",\n ".join(f'"{v}" for parameter {p}' for p, v in invalid_params)
)
errors.append(msg)

Expand Down

0 comments on commit dfd916f

Please sign in to comment.