From 83a28ed9e8f0a8bdc7ceed194d204d19557fb6f7 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 28 Jul 2026 04:08:38 +0000 Subject: [PATCH] [IMP] script todo: add "principal" choice to infra (one main VM per distro) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The infra distribution prompt now accepts "principal" (alongside numbers and "all"): it deploys the default version of each distro — ubuntu 24.04, debian 12, fedora 42 — one VM each. The default version is also marked with a * in the distro listing so it is visible. Co-Authored-By: Claude Opus 4.8 (1M context) --- script/todo/todo.py | 87 +++++++++++++++++++++++++--------------- script/todo/todo_i18n.py | 8 ++++ 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/script/todo/todo.py b/script/todo/todo.py index 70de4dd..dd178de 100755 --- a/script/todo/todo.py +++ b/script/todo/todo.py @@ -1690,47 +1690,68 @@ class TODO: return distros = list(mod.DISTROS) - # 1) Distributions (multi-sélection) ou catalogue complet. + # 1) Distributions : multi-sélection, catalogue complet, ou principal + # (la version par défaut de chaque distro, marquée d'un *). print(f"\n{t('Distributions:')}") for i, d in enumerate(distros, 1): - vers = ", ".join(mod.DISTROS[d][0]) + default_v = mod.DISTROS[d][1] + vers = ", ".join( + (v + " *" if v == default_v else v) for v in mod.DISTROS[d][0] + ) print(f" [{i}] {d} ({vers})") print(f" [all] {t('Whole catalog (every version)')}") - raw = input(t("Selection (numbers, or 'all', default: all): ")).strip() - catalog_all = raw.lower() in ("", "all", "*") - sel_distros = ( - distros - if catalog_all - else self._parse_index_selection(raw.lower(), distros) + print( + f" [principal] {t('The main version of each distro (marked *)')}" ) - if not sel_distros: - print(t("Nothing selected.")) - return + raw = ( + input( + t("Selection (numbers, 'all' or 'principal', default: all): ") + ) + .strip() + .lower() + ) + catalog_all = raw in ("", "all", "*") + principal = raw in ("principal", "each", "p") - # 2) Versions par distro (multi-sélection) ; « all » si catalogue. selected = [] # (distro, version, ram_mb, disk_str) - for d in sel_distros: - versions_map = mod.DISTROS[d][0] - vlist = list(versions_map) - if catalog_all: - chosen = vlist - else: - print(f"\n{t('Versions for')} {d} :") - for i, v in enumerate(vlist, 1): + if principal: + # Une VM par distro : sa version par défaut. + for d in distros: + versions_map, default_v = mod.DISTROS[d] + _c, _o, ram, disk = versions_map[default_v] + selected.append((d, default_v, ram, disk)) + else: + sel_distros = ( + distros + if catalog_all + else self._parse_index_selection(raw, distros) + ) + if not sel_distros: + print(t("Nothing selected.")) + return + # 2) Versions par distro (multi-sélection) ; « all » si catalogue. + for d in sel_distros: + versions_map = mod.DISTROS[d][0] + vlist = list(versions_map) + if catalog_all: + chosen = vlist + else: + print(f"\n{t('Versions for')} {d} :") + for i, v in enumerate(vlist, 1): + _c, _o, ram, disk = versions_map[v] + print(f" [{i}] {v} (RAM≥{ram}Mo, {disk})") + print(f" [all] {t('select all')}") + r = input( + t("Selection (numbers, or 'all', default: all): ") + ).strip() + chosen = ( + vlist + if r.lower() in ("", "all", "*") + else self._parse_index_selection(r.lower(), vlist) + ) + for v in chosen: _c, _o, ram, disk = versions_map[v] - print(f" [{i}] {v} (RAM≥{ram}Mo, {disk})") - print(f" [all] {t('select all')}") - r = input( - t("Selection (numbers, or 'all', default: all): ") - ).strip() - chosen = ( - vlist - if r.lower() in ("", "all", "*") - else self._parse_index_selection(r.lower(), vlist) - ) - for v in chosen: - _c, _o, ram, disk = versions_map[v] - selected.append((d, v, ram, disk)) + selected.append((d, v, ram, disk)) if not selected: print(t("Nothing selected.")) return diff --git a/script/todo/todo_i18n.py b/script/todo/todo_i18n.py index cee0c90..fd07bb8 100644 --- a/script/todo/todo_i18n.py +++ b/script/todo/todo_i18n.py @@ -1330,6 +1330,14 @@ TRANSLATIONS = { "fr": "Tout le catalogue (chaque version)", "en": "Whole catalog (every version)", }, + "The main version of each distro (marked *)": { + "fr": "La version principale de chaque distro (marquée *)", + "en": "The main version of each distro (marked *)", + }, + "Selection (numbers, 'all' or 'principal', default: all): ": { + "fr": "Sélection (numéros, « all » ou « principal », défaut : all) : ", + "en": "Selection (numbers, 'all' or 'principal', default: all): ", + }, "Selection (numbers, or 'all', default: all): ": { "fr": "Sélection (numéros, ou « all », défaut : all) : ", "en": "Selection (numbers, or 'all', default: all): ",