Skip to content

Commit

Permalink
fix: wizard question don't allow escape, fix automatic logic
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Oct 1, 2024
1 parent 991431d commit d3ed1dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions everyvoice/wizard/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def effect(self):

class DatasetPermissionStep(Step):
DEFAULT_NAME = StepNames.dataset_permission_step
# REVERSIBLE not declared because this class overrides is_reversible instead
REVERSIBLE = True
choices = (
"No, I don't have permission to use this data.",
"Yes, I do have permission to use this data.",
Expand All @@ -83,10 +83,9 @@ def effect(self):
self.children = ()
self.tour.remove_dataset(self.state_subset)

def is_reversible(self):
# Permission can be revoked, but if you said no you can't go back because we
# destroy too much of the state in the effect(). Just pick another data file.
return not self.response.startswith("No")
# Permission can be revoked, but if you said no you can't go back because
# we destroy too much of the state here. Just pick another data file.
self.REVERSIBLE = False

def undo(self):
# Do not call super().undo() here! We don't want to remove the dataset steps
Expand Down Expand Up @@ -530,13 +529,16 @@ class HasSpeakerStep(Step):

def prompt(self):
if self.state[StepNames.filelist_format_step] == "festival":
self.AUTOMATIC = True
return "no"
elif len(self.state.get("selected_headers", [])) >= len(
self.state["filelist_data_list"][0]
):
self.AUTOMATIC = True
rich_print("No columns left, we will assume you have no speaker column.")
return "no"
else:
self.AUTOMATIC = False
return get_response_from_menu_prompt(
prompt_text="Does your data have a column/value for the speaker?",
choices=self.choices,
Expand Down Expand Up @@ -621,13 +623,16 @@ class HasLanguageStep(Step):

def prompt(self):
if self.state[StepNames.filelist_format_step] == "festival":
self.AUTOMATIC = True
return "no"
elif len(self.state.get("selected_headers", [])) >= len(
self.state["filelist_data_list"][0]
):
rich_print("No columns left, we will assume you have no language column.")
self.AUTOMATIC = True
return "no"
else:
self.AUTOMATIC = False
return get_response_from_menu_prompt(
prompt_text="Does your data have a column/value for the language?",
choices=self.choices,
Expand Down
1 change: 1 addition & 0 deletions everyvoice/wizard/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def get_response_from_menu_prompt(
show_multi_select_hint=multi,
show_search_hint=search,
status_bar_style=("fg_gray", "bg_black"),
quit_keys=(),
)
selection = menu.show()
sys.stdout.write("\033[K")
Expand Down

0 comments on commit d3ed1dc

Please sign in to comment.