art: Indent the completion text and use textwrap.dedent
from __future__ import absolute_import
import sys
+import textwrap
from pip.basecommand import Command
@@ -17,7 +18,8 @@ _pip_completion()
PIP_AUTO_COMPLETE=1 $1 ) )
}
complete -o default -F _pip_completion pip
-""", 'zsh': """
+ """,
+ 'zsh': """
function _pip_completion {
local words cword
read -Ac words
@@ -27,7 +29,8 @@ function _pip_completion {
PIP_AUTO_COMPLETE=1 $words[1] ) )
}
compctl -K _pip_completion pip
-""", 'fish': """
+ """,
+ 'fish': """
function __fish_complete_pip
set -lx COMP_WORDS (commandline -o) ""
set -lx COMP_CWORD (math (contains -i -- (commandline -t) $COMP_WORDS)-1)
@@ -35,7 +38,8 @@ function __fish_complete_pip
string split \\ -- (eval $COMP_WORDS[1])
end
complete -fa "(__fish_complete_pip)" -c pip
-"""}
+ """
+}
class CompletionCommand(Command):
@@ -75,7 +79,9 @@ class CompletionCommand(Command):
shells = COMPLETION_SCRIPTS.keys()
shell_options = ['--' + shell for shell in sorted(shells)]
if options.shell in shells:
- script = COMPLETION_SCRIPTS.get(options.shell, '')
+ script = textwrap.dedent(
+ COMPLETION_SCRIPTS.get(options.shell, '')
+ )
print(BASE_COMPLETION % {'script': script, 'shell': options.shell})
else:
sys.stderr.write(
