This commit is contained in:
Kovid Goyal 2013-06-10 06:13:58 +05:30
parent fc4f0f4379
commit 6306fbcd8c

View File

@ -15,7 +15,7 @@ from calibre import CurrentDir
entry_points = { entry_points = {
'console_scripts': [ \ 'console_scripts': [
'ebook-device = calibre.devices.cli:main', 'ebook-device = calibre.devices.cli:main',
'ebook-meta = calibre.ebooks.metadata.cli:main', 'ebook-meta = calibre.ebooks.metadata.cli:main',
'ebook-convert = calibre.ebooks.conversion.cli:main', 'ebook-convert = calibre.ebooks.conversion.cli:main',
@ -196,7 +196,8 @@ class ZshCompleter(object): # {{{
def opts_and_exts(self, name, op, exts, cover_opts=('--cover',), def opts_and_exts(self, name, op, exts, cover_opts=('--cover',),
opf_opts=('--opf',), file_map={}): opf_opts=('--opf',), file_map={}):
if not self.dest: return if not self.dest:
return
exts = set(exts).union(x.upper() for x in exts) exts = set(exts).union(x.upper() for x in exts)
pats = ('*.%s'%x for x in exts) pats = ('*.%s'%x for x in exts)
extra = ("'*:filename:_files -g \"%s\"' "%' '.join(pats),) extra = ("'*:filename:_files -g \"%s\"' "%' '.join(pats),)
@ -206,7 +207,8 @@ class ZshCompleter(object): # {{{
self.commands[name] = txt self.commands[name] = txt
def opts_and_words(self, name, op, words, takes_files=False): def opts_and_words(self, name, op, words, takes_files=False):
if not self.dest: return if not self.dest:
return
extra = ("'*:filename:_files' ",) if takes_files else () extra = ("'*:filename:_files' ",) if takes_files else ()
opts = '\\\n '.join(tuple(self.get_options(op())) + extra) opts = '\\\n '.join(tuple(self.get_options(op())) + extra)
txt = '_arguments -s \\\n ' + opts txt = '_arguments -s \\\n ' + opts
@ -273,7 +275,8 @@ class ZshCompleter(object): # {{{
): ):
for fmt in fmts: for fmt in fmts:
is_input = group_title == input_group is_input = group_title == input_group
if is_input and fmt in {'rar', 'zip', 'oebzip'}: continue if is_input and fmt in {'rar', 'zip', 'oebzip'}:
continue
p = (get_parser(input_fmt=fmt) if is_input p = (get_parser(input_fmt=fmt) if is_input
else get_parser(output_fmt=fmt)) else get_parser(output_fmt=fmt))
opts = None opts = None
@ -282,7 +285,8 @@ class ZshCompleter(object): # {{{
opts = [o for o in group.option_list if opts = [o for o in group.option_list if
'--pretty-print' not in o._long_opts and '--pretty-print' not in o._long_opts and
'--input-encoding' not in o._long_opts] '--input-encoding' not in o._long_opts]
if not opts: continue if not opts:
continue
opts = '\\\n '.join(tuple(self.get_options(opts))) opts = '\\\n '.join(tuple(self.get_options(opts)))
w('\n%s() {'%(func%fmt)) w('\n%s() {'%(func%fmt))
w('\n _arguments -s \\\n ' + opts) w('\n _arguments -s \\\n ' + opts)
@ -407,7 +411,6 @@ class PostInstall:
self.warnings.append((args, kwargs)) self.warnings.append((args, kwargs))
sys.stdout.flush() sys.stdout.flush()
def __init__(self, opts, info=prints, warn=None, manifest=None): def __init__(self, opts, info=prints, warn=None, manifest=None):
self.opts = opts self.opts = opts
self.info = info self.info = info
@ -482,7 +485,6 @@ class PostInstall:
raise raise
self.task_failed('Creating uninstaller failed') self.task_failed('Creating uninstaller failed')
def setup_completion(self): # {{{ def setup_completion(self): # {{{
try: try:
self.info('Setting up command-line completion...') self.info('Setting up command-line completion...')
@ -745,7 +747,7 @@ def opts_and_words(name, op, words, takes_files=False):
opts = '|'.join(options(op)) opts = '|'.join(options(op))
words = '|'.join([w.replace("'", "\\'") for w in words]) words = '|'.join([w.replace("'", "\\'") for w in words])
fname = name.replace('-', '_') fname = name.replace('-', '_')
return ('_'+fname+'()'+\ return ('_'+fname+'()'+
''' '''
{ {
local cur opts local cur opts
@ -922,3 +924,4 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())