Skip to content

Commit 71bdd2d

Browse files
committed
tidy up
1 parent a0ef9fd commit 71bdd2d

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

src/virtualship/cli/_plan.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@
4747
TimeRange,
4848
)
4949

50-
# TODO list:
51-
52-
# Need to build TESTS for the UI!
53-
# - look into best way of testing this kind of thing...
54-
5550
UNEXPECTED_MSG_ONSAVE = (
5651
"Please ensure that:\n"
5752
"\n1) All typed entries are valid (all boxes in all sections must have green borders and no warnings).\n"
@@ -75,16 +70,7 @@ def log_exception_to_file(
7570
filename: str = "virtualship_error.txt",
7671
context_message: str = "Error occurred:",
7772
):
78-
"""
79-
Log an exception and its traceback to a file.
80-
81-
Args:
82-
exception (Exception): The exception to log.
83-
path (str): Directory where the log file will be saved.
84-
filename (str, optional): Log file name. Defaults to 'virtualship_error.txt'.
85-
context_message (str, optional): Message to write before the traceback.
86-
87-
"""
73+
"""Log an exception and its traceback to a file."""
8874
error_log_path = os.path.join(path, filename)
8975
with open(error_log_path, "w") as f:
9076
f.write(f"{context_message}\n")
@@ -166,7 +152,7 @@ def compose(self) -> ComposeResult:
166152
yield Select(
167153
[
168154
(str(year), year)
169-
# TODO: change from hard coding...flexibility for different datasets...
155+
# TODO: change from hard coding? ...flexibility for different datasets...
170156
for year in range(
171157
2022,
172158
datetime.datetime.now().year + 1,
@@ -233,11 +219,11 @@ def compose(self) -> ComposeResult:
233219
raise UnexpectedError(unexpected_msg_compose(e)) from None
234220

235221
def copy_from_previous(self) -> None:
222+
"""Copy inputs from previous waypoint widget (time and instruments only, not lat/lon)."""
236223
try:
237224
if self.index > 0:
238225
schedule_editor = self.parent
239226
if schedule_editor:
240-
# only copy time components and instruments, not lat/lon
241227
time_components = ["year", "month", "day", "hour", "minute"]
242228
for comp in time_components:
243229
prev = schedule_editor.query_one(f"#wp{self.index - 1}_{comp}")
@@ -308,6 +294,8 @@ def compose(self) -> ComposeResult:
308294
for i, waypoint in enumerate(self.schedule.waypoints):
309295
yield WaypointWidget(waypoint, i)
310296

297+
# SECTION: "Space-Time Region"
298+
311299
with Collapsible(
312300
title="[b]Space-Time Region[/b] (advanced users only)",
313301
collapsed=True,
@@ -570,7 +558,6 @@ def save_changes(self) -> bool:
570558
return True
571559

572560
except Exception as e:
573-
# write error log
574561
log_exception_to_file(
575562
e, self.path, context_message="Error saving ship config:"
576563
)
@@ -721,7 +708,7 @@ def compose(self) -> ComposeResult:
721708
yield Label(" SeaSeven:")
722709
yield Switch(value=not is_deep, id="adcp_shallow")
723710

724-
## SECTION: "Instrument Configurations (advanced users only)""
711+
## SECTION: "Instrument Configurations""
725712

726713
with Collapsible(
727714
title="[b]Instrument Configurations[/b] (advanced users only)",
@@ -914,7 +901,6 @@ def save_changes(self) -> bool:
914901
return True
915902

916903
except Exception as e:
917-
# write error log
918904
log_exception_to_file(
919905
e, self.path, context_message="Error saving ship config:"
920906
)

src/virtualship/cli/validator_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ def make_validator(condition, reference, value_type):
120120
Docstrings will be used to generate informative UI invalid entry messages, so them being informative and accurate is important!
121121
122122
N.B. #2 Textual validator tools do not currently support additional arguments (such as 'reference' values) being fed into the validator functions (such as is_gt0) at present.
123-
Therefore, reference values for the conditions cannot be fed in dynamically and necessitates "hard-coding" the condition and reference value combination.
124-
At present, Pydantic models in VirtualShip only require gt/ge/lt/le relative to **0.0** so "reference" is always checked as being == 0.0
125-
Additional custom conditions can be "hard-coded" as new condition and reference combinations if Pydantic model specifications change in the future and/or new instruments are added to VirtualShip etc.
123+
Therefore, reference values for the conditions cannot be fed in dynamically and necessitates 'hard-coding' the condition and reference value combination.
124+
At present, Pydantic models in VirtualShip only require gt/ge/lt/le relative to **0.0** so the 'reference' value is always checked as being == 0.0
125+
Additional custom conditions can be 'hard-coded' as new condition and reference combinations if Pydantic model specifications change in the future and/or new instruments are added to VirtualShip etc.
126126
TODO: Perhaps there's scope here though for a more flexible implementation in a future PR...
127127
128128
"""

0 commit comments

Comments
 (0)