[FIX] script todo: accept o/oui at every yes/no prompt

Generalise the _is_yes() helper (y/yes/o/oui) across the whole file so
French answers work everywhere, and add _is_no() (n/no/non) for the
default-yes prompts. Converted: system-install, Pycharm, SSH-password
(default yes via _is_no), template overwrite, keep-temp-database (was
locale-gated, now accepts both), git-repo fetch and the mobile
personalize/debug/picture prompts. Drop the now-unused get_lang import.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mathieu Benoit 2026-07-19 07:10:55 +00:00
parent 84f63c326a
commit ca796a67a4

View file

@ -27,7 +27,7 @@ from script.config import config_file
from script.execute import execute
from script.todo.database_manager import DatabaseManager
from script.todo.kdbx_manager import KdbxManager
from script.todo.todo_i18n import get_lang, lang_is_configured, set_lang, t
from script.todo.todo_i18n import lang_is_configured, set_lang, t
from script.todo.version_manager import get_odoo_version
ERROR_LOG_PATH = ".erplibre.error.txt"
@ -293,7 +293,7 @@ class TODO:
.strip()
.lower()
)
if first_installation_input == "y":
if self._is_yes(first_installation_input):
cmd = "./script/version/update_env_version.py --install"
self.execute.exec_command_live(cmd, source_erplibre=True)
print("Wait after OS installation before continue.")
@ -323,7 +323,7 @@ class TODO:
pycharm_configuration_input = (
input("💬 Open Pycharm? (Y/N): ").strip().lower()
)
if pycharm_configuration_input == "y":
if self._is_yes(pycharm_configuration_input):
pycharm_bin = "pycharm" if has_pycharm else "pycharm-community"
cmd = f"cd {os.getcwd()} && {pycharm_bin} ./"
@ -921,12 +921,9 @@ class TODO:
use_password = False
if not ssh_key:
ans = (
input(t("No SSH key found. Set a password instead? (Y/n): "))
.strip()
.lower()
)
use_password = ans != "n"
ans = input(t("No SSH key found. Set a password instead? (Y/n): "))
# Défaut oui : tout sauf une réponse négative explicite vaut oui.
use_password = not self._is_no(ans)
force = False
if not dry_run:
@ -1028,6 +1025,12 @@ class TODO:
"""Réponse affirmative, FR et EN (o/oui/y/yes)."""
return ans.strip().lower() in ("y", "yes", "o", "oui")
@staticmethod
def _is_no(ans):
"""Réponse négative explicite, FR et EN (n/no/non). Utile pour les
invites « défaut oui » tout sauf « non » vaut oui."""
return ans.strip().lower() in ("n", "no", "non")
@staticmethod
def _host_free_ram_mb():
"""RAM disponible de l'hôte en Mo (MemAvailable), 0 si inconnu."""
@ -1932,10 +1935,8 @@ class TODO:
if os.path.exists(dest_file):
print(f"{t('File already exists: ')}{dest_file}")
overwrite = input(
t("Do you want to overwrite the file? (y/Y): ")
).strip()
if overwrite not in ("y", "Y"):
overwrite = input(t("Do you want to overwrite the file? (y/Y): "))
if not self._is_yes(overwrite):
print(t("Nothing to do."))
return
@ -2420,11 +2421,8 @@ class TODO:
print(f"\n{t('Tests failed with return code')} {status_code}")
# Step 4: Cleanup
lang = get_lang()
keep_input = (
input(t("Keep the temporary database? (y/N): ")).strip().lower()
)
keep = keep_input in (("o", "oui") if lang == "fr" else ("y", "yes"))
keep_input = input(t("Keep the temporary database? (y/N): "))
keep = self._is_yes(keep_input)
if keep:
print(f"{t('Database kept')}: {db_name}")
else:
@ -2749,7 +2747,7 @@ class TODO:
git_repo_update_input = input(
"💬 Would you like to fetch all your git repositories, you need it (y/Y) : "
)
if git_repo_update_input.strip().lower() == "y":
if self._is_yes(git_repo_update_input):
status = self.execute.exec_command_live(
f"./script/manifest/update_manifest_local_dev.sh",
source_erplibre=False,
@ -2867,7 +2865,7 @@ class TODO:
do_personalize = input(
"Do you want to personalize the mobile application (Y) : "
)
if do_personalize.strip().lower() == "y":
if self._is_yes(do_personalize):
project_name = (
input(
f'Your project name (Separate by space in title), default "{default_project_name}" : '
@ -2892,19 +2890,14 @@ class TODO:
).strip()
or default_project_note_subject
)
do_debug = (
do_debug = self._is_yes(
input("Compilation with debug information, default No (Y) : ")
.strip()
.lower()
== "y"
)
do_change_picture_menu = (
do_change_picture_menu = self._is_yes(
input(
"Want to change picture from menu, you need android-studio (Y) : "
"Want to change picture from menu, you need"
" android-studio (Y) : "
)
.strip()
.lower()
== "y"
)
# Rename with script bash