diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-10-24 06:55:34 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-10-24 06:55:34 +0000 |
commit | cccca42d0470d9a2a972e8130418d82e97aa89b9 (patch) | |
tree | 2c45e45ab95b2ab8e7eb3b793ffee6a69638bd1b /pym/_emerge/actions.py | |
parent | 40dd1f931f49b543229be30df8df303de987b8d8 (diff) | |
download | portage-cccca42d0470d9a2a972e8130418d82e97aa89b9.tar.gz portage-cccca42d0470d9a2a972e8130418d82e97aa89b9.tar.bz2 portage-cccca42d0470d9a2a972e8130418d82e97aa89b9.zip |
Bug #134466 - Add a --ask-enter-invalid option. When used together with the
--ask option, interpret a single "Enter" key press as invalid input. This
helps prevent accidental acceptance of the first choice.
svn path=/main/trunk/; revision=14710
Diffstat (limited to 'pym/_emerge/actions.py')
-rw-r--r-- | pym/_emerge/actions.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 916d6a8ba..bd668985f 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -134,6 +134,7 @@ def action_build(settings, trees, mtimedb, pretend = "--pretend" in myopts fetchonly = "--fetchonly" in myopts or "--fetch-all-uri" in myopts ask = "--ask" in myopts + enter_invalid = '--ask-enter-invalid' in myopts nodeps = "--nodeps" in myopts oneshot = "--oneshot" in myopts or "--onlydeps" in myopts tree = "--tree" in myopts @@ -340,7 +341,7 @@ def action_build(settings, trees, mtimedb, else: prompt="Would you like to merge these packages?" print() - if "--ask" in myopts and userquery(prompt) == "No": + if "--ask" in myopts and userquery(prompt, enter_invalid) == "No": print() print("Quitting.") print() @@ -441,6 +442,7 @@ def action_build(settings, trees, mtimedb, return retval def action_config(settings, trees, myopts, myfiles): + enter_invalid = '--ask-enter-invalid' in myopts if len(myfiles) != 1: print(red("!!! config can only take a single package atom at this time\n")) sys.exit(1) @@ -470,7 +472,7 @@ def action_config(settings, trees, myopts, myfiles): print(options[-1]+") "+pkg) print("X) Cancel") options.append("X") - idx = userquery("Selection?", options) + idx = userquery("Selection?", enter_invalid, responses=options) if idx == "X": sys.exit(0) pkg = pkgs[int(idx)-1] @@ -485,7 +487,7 @@ def action_config(settings, trees, myopts, myfiles): print() if "--ask" in myopts: - if userquery("Ready to configure "+pkg+"?") == "No": + if userquery("Ready to configure %s?" % pkg, enter_invalid) == "No": sys.exit(0) else: print("Configuring pkg...") @@ -1142,6 +1144,7 @@ def calc_depclean(settings, trees, ldpath_mtimes, return 0, [], False, required_pkgs_total def action_deselect(settings, trees, opts, atoms): + enter_invalid = '--ask-enter-invalid' in opts root_config = trees[settings['ROOT']]['root_config'] world_set = root_config.sets['selected'] if not hasattr(world_set, 'update'): @@ -1184,7 +1187,7 @@ def action_deselect(settings, trees, opts, atoms): if '--ask' in opts: prompt = "Would you like to remove these " + \ "packages from your world favorites?" - if userquery(prompt) == 'No': + if userquery(prompt, enter_invalid) == 'No': return os.EX_OK remaining = set(world_set) @@ -1679,6 +1682,7 @@ def action_search(root_config, myopts, myfiles, spinner): searchinstance.output() def action_sync(settings, trees, mtimedb, myopts, myaction): + enter_invalid = '--ask-enter-invalid' in myopts xterm_titles = "notitles" not in settings.features emergelog(xterm_titles, " === sync") portdb = trees[settings["ROOT"]]["porttree"].dbapi @@ -1924,7 +1928,9 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): if (retries==0): if "--ask" in myopts: - if userquery("Do you want to sync your Portage tree with the mirror at\n" + blue(dosyncuri) + bold("?"))=="No": + if userquery("Do you want to sync your Portage tree " + \ + "with the mirror at\n" + blue(dosyncuri) + bold("?"), + enter_invalid) == "No": print() print("Quitting.") print() |