From 07cf1b91569e1be7e2dfd61b4c4c59648a8ec8d1 Mon Sep 17 00:00:00 2001 From: Samuel BAUER Date: Thu, 14 Apr 2011 15:23:07 +0700 Subject: [PATCH] emerge: Added --misspell-suggestion as an option (rather than a feature) --- man/emerge.1 | 5 +++++ pym/_emerge/depgraph.py | 3 ++- pym/_emerge/help.py | 16 +++++++++++++--- pym/_emerge/main.py | 6 ++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/man/emerge.1 b/man/emerge.1 index 2693b67..3ec1f10 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -437,6 +437,11 @@ This option is recommended for use in combination with \fB\-\-jobs\fR in order to avoid excess load. See \fBmake\fR(1) for information about analogous options that should be configured via \fBMAKEOPTS\fR in \fBmake.conf\fR(5). + .TP ++.BR "\-\-misspell-suggestions < y | n >" +Enable or disable misspell suggestions. By default emerge will return a +list of packages with similar name, when a package given in argument +doesn't exist. .TP .BR "\-\-newuse " (\fB\-N\fR) Tells emerge to include installed packages where USE diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 391c845..1bc1ee6 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -2741,7 +2741,8 @@ class depgraph(object): mask_docs = True else: writemsg_stdout("\nemerge: there are no ebuilds to satisfy "+green(xinfo)+".\n", noiselevel=-1) - if isinstance(myparent, AtomArg): + if self._frozen_config.myopts.get('--misspell-suggestions', 'y') == 'y' and \ + isinstance(myparent, AtomArg): cp = myparent.atom.cp.lower() cat, pkg = portage.catsplit(cp) if cat == "null": diff --git a/pym/_emerge/help.py b/pym/_emerge/help.py index a120f54..61ede2e 100644 --- a/pym/_emerge/help.py +++ b/pym/_emerge/help.py @@ -17,11 +17,11 @@ def shorthelp(): print(bold("Options:")+" "+green("-")+"["+green("abBcCdDefgGhjkKlnNoOpPqrsStuvV")+"]") print(" [ " + green("--color")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ] [ "+green("--columns")+" ]") print(" [ "+green("--complete-graph")+" ] [ "+green("--deep")+" ]") - print(" [ "+green("--jobs") + " " + turquoise("JOBS")+" ] [ "+green("--keep-going")+" ] [ " + green("--load-average")+" " + turquoise("LOAD") + " ]") + print(" [ "+green("--jobs") + " " + turquoise("JOBS")+" ] [ "+green("--keep-going")+" ] [ " + green("--load-average")+" " + turquoise("LOAD") + " ]") print(" [ "+green("--newuse")+" ] [ "+green("--noconfmem")+" ] [ "+green("--nospinner")+" ]") - print(" [ "+green("--oneshot")+" ] [ "+green("--onlydeps")+" ]") + print(" [ "+green("--oneshot")+" ] [ "+green("--onlydeps")+" ] [ " + green("--misspell-suggestions")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ]") print(" [ "+green("--reinstall ")+turquoise("changed-use")+" ] [ " + green("--with-bdeps")+" < " + turquoise("y") + " | "+ turquoise("n")+" > ]") - print(bold("Actions:")+" [ "+green("--depclean")+" | "+green("--list-sets")+" | "+green("--search")+" | "+green("--sync")+" | "+green("--version")+" ]") + print(bold("Actions:")+" [ "+green("--depclean")+" | "+green("--list-sets")+" | "+green("--search")+" | "+green("--sync")+" | "+green("--version")+" ]") def help(myopts, havecolor=1): # TODO: Implement a wrap() that accounts for console color escape codes. @@ -522,6 +522,16 @@ def help(myopts, havecolor=1): for line in wrap(desc, desc_width): print(desc_indent + line) print() + print(" " + green("--misspell-suggestions") + " [ %s | %s ]" % \ + (turquoise("y"), turquoise("n"))) + desc = "Enable or disable misspell suggestions. By default " + \ + "emerge will return a list of packages with similar " + \ + "name, when a package given in argument doesn't exist. " + \ + "PORTAGE_DEFAULT_OPT=\"--misspell-suggestions=n\" in " + \ + "make.conf disable this behavior" + for line in wrap(desc, desc_width): + print(desc_indent + line) + print() print(" "+green("--noconfmem")) print(" Portage keeps track of files that have been placed into") print(" CONFIG_PROTECT directories, and normally it will not merge the") diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 96fee89..a349ed7 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -778,6 +778,12 @@ def parse_opts(tmpcmdline, silent=False): "choices" : true_y_or_n }, + "--misspell-suggestions": { + "help" : "enable package name suggestions when not existing", + "type" : "choice", + "choices" : true_y_or_n + }, + } if _ENABLE_DYN_LINK_MAP: -- 1.7.3.4