mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Python 3 compatibility fix in make_completions.py
This commit is contained in:
parent
6e3a823b7b
commit
19d14c7c3a
1 changed files with 13 additions and 7 deletions
|
@ -1,7 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import commands
|
||||
try:
|
||||
import commands
|
||||
except ImportError:
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
# Regexes for performing cleanup
|
||||
|
@ -12,13 +15,13 @@ cl = { re.compile(r"-[ \t]*\n[ \t\r]+" ):"",
|
|||
re.compile(r"[ \n\t\r]$"):"" }
|
||||
|
||||
def header(cmd):
|
||||
print '''#
|
||||
# Command specific completions for the %s command.
|
||||
print('''#
|
||||
# Command specific completions for the {0} command.
|
||||
# These completions were generated from the commands
|
||||
# man page by the make_completions.py script, but may
|
||||
# have been hand edited since.
|
||||
#
|
||||
''' % (cmd)
|
||||
'''.format(cmd))
|
||||
|
||||
def up_first(s):
|
||||
return s[0].upper() + s[1:]
|
||||
|
@ -57,13 +60,16 @@ def print_completion( cmd, switch_arr, arg, desc ):
|
|||
|
||||
res += " --description '%s'" % (up_first(escape_quotes(clean(desc))))
|
||||
|
||||
print res
|
||||
print(res)
|
||||
|
||||
cmd = sys.argv[1]
|
||||
|
||||
header(cmd)
|
||||
|
||||
man = commands.getoutput( "man %s | col -b" % cmd )
|
||||
try:
|
||||
man = commands.getoutput( "man %s | col -b".format(cmd))
|
||||
except NameError:
|
||||
man = subprocess.getoutput( "man %s | col -b".format(cmd))
|
||||
|
||||
remainder = man
|
||||
|
||||
|
@ -152,7 +158,7 @@ for c in man:
|
|||
desc += c
|
||||
|
||||
else:
|
||||
print "Unknown mode", mode
|
||||
print("Unknown mode {0}".format(mode))
|
||||
|
||||
pc = c
|
||||
|
||||
|
|
Loading…
Reference in a new issue