Skip to content

Commit 094470e

Browse files
committed
Allow setup wizard to skip sections if they are disabled; updated font styles of config key descriptions
1 parent 8db6865 commit 094470e

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/murfey/cli/generate_config.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def ask_for_input(parameter: str, again: bool = False):
9898
"an" if parameter.lower().startswith(("a", "e", "i", "o", "u")) else "a"
9999
)
100100
)
101-
+ f" {parameter}? [bold cyan](y/n)[/bold cyan]"
101+
+ f" {parameter}? [bold bright_magenta](y/n)[/bold bright_magenta]"
102102
)
103103
return ask_for_permission(message)
104104

@@ -107,15 +107,15 @@ def confirm_overwrite(value: str):
107107
"""
108108
Asks the user if a value that already exists should be overwritten.
109109
"""
110-
message = f"{value!r} already exists; do you wish to overwrite it? [bold cyan](y/n)[/bold cyan]"
110+
message = f"{value!r} already exists; do you wish to overwrite it? [bold bright_magenta](y/n)[/bold bright_magenta]"
111111
return ask_for_permission(message)
112112

113113

114114
def confirm_duplicate(value: str):
115115
"""
116116
Asks the user if a duplicate value should be allowed.
117117
"""
118-
message = f"{value!r} already exists; do you want to add a duplicate? [bold cyan](y/n)[/bold cyan]"
118+
message = f"{value!r} already exists; do you want to add a duplicate? [bold bright_magenta](y/n)[/bold bright_magenta]"
119119
return ask_for_permission(message)
120120

121121

@@ -418,7 +418,9 @@ def populate_field(key: str, field: ModelField, debug: bool = False) -> Any:
418418
except ValidationError as error:
419419
if debug:
420420
console.print(error, style="bright_red")
421-
console.print(f"Invalid input for {key!r}. Please try again")
421+
console.print(
422+
f"Invalid input for {key!r}. Please try again", style="bright_red"
423+
)
422424
continue
423425

424426

@@ -521,7 +523,7 @@ def get_software_name() -> str:
521523
def ask_about_settings_file() -> bool:
522524
message = (
523525
"Does this software package have a settings file that needs modification? "
524-
"[bold cyan](y/n)[/bold cyan]"
526+
"[bold bright_magenta](y/n)[/bold bright_magenta]"
525527
)
526528
return ask_for_permission(message)
527529

@@ -542,7 +544,7 @@ def get_settings_tree_path() -> str:
542544
"This is where aquisition software packages present on the instrument machine "
543545
"can be specified, along with the output file names and extensions that are of "
544546
"interest.",
545-
style="italic bright_cyan",
547+
style="bright_white",
546548
)
547549
package_info: dict = {}
548550
category = "software package"
@@ -555,7 +557,7 @@ def get_settings_tree_path() -> str:
555557
)
556558
console.print(
557559
"Name of the acquisition software installed on this instrument.",
558-
style="italic bright_cyan",
560+
style="bright_white",
559561
)
560562
console.print(
561563
"Options: 'autotem', 'epu', 'leica', 'serialem', 'tomo'",
@@ -588,7 +590,7 @@ def get_settings_tree_path() -> str:
588590
"in order to ensure files are saved to the desired folders. The paths to "
589591
"the files and the path to the nodes in the settings files both need to be "
590592
"provided.",
591-
style="italic bright_cyan",
593+
style="bright_white",
592594
)
593595
settings_file: Optional[Path] = (
594596
get_file_path(
@@ -610,7 +612,7 @@ def get_settings_tree_path() -> str:
610612
"Different software packages will generate different output files. Only "
611613
"files with certain extensions and keywords in their filenames are needed "
612614
"for data processing. They are listed out here.",
613-
style="italic bright_cyan",
615+
style="bright_white",
614616
)
615617
extensions_and_substrings: dict[str, list[str]] = construct_dict(
616618
dict_name="file extension configuration",
@@ -873,6 +875,9 @@ def get_upstream_data_tiff_locations(
873875
"upstream_data_tiff_locations",
874876
):
875877
field = MachineConfig.__fields__[key]
878+
# Skip everything in this section if data transfer is set to False
879+
if config.get("data_transfer_enabled", None) is False:
880+
continue
876881
# Construct more complicated data structures
877882
if key == "upstream_data_directories":
878883
validated_value: Any = get_upstream_data_directories(key, field, debug)
@@ -934,6 +939,9 @@ def add_recipes(key: str, field: ModelField, debug: bool = False) -> dict[str, s
934939
"initial_model_search_directory",
935940
):
936941
field = MachineConfig.__fields__[key]
942+
# Skip this section of processing is disabled
943+
if config.get("processing_enabled", None) is False:
944+
continue
937945
# Handle complex keys
938946
if key == "recipes":
939947
validated_value: Any = add_recipes(key, field, debug)

0 commit comments

Comments
 (0)