mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
fc4f0f4379
commit
6306fbcd8c
@ -7,7 +7,7 @@ import sys, os, cPickle, textwrap, stat
|
|||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import __appname__, prints, guess_type
|
from calibre import __appname__, prints, guess_type
|
||||||
from calibre.constants import islinux, isnetbsd, isbsd
|
from calibre.constants import islinux, isnetbsd, isbsd
|
||||||
from calibre.customize.ui import all_input_formats
|
from calibre.customize.ui import all_input_formats
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
@ -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',
|
||||||
@ -123,7 +123,7 @@ os.remove(os.path.abspath(__file__))
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class ZshCompleter(object): # {{{
|
class ZshCompleter(object): # {{{
|
||||||
|
|
||||||
def __init__(self, opts):
|
def __init__(self, opts):
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
@ -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,8 +485,7 @@ 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...')
|
||||||
from calibre.ebooks.metadata.cli import option_parser as metaop, filetypes as meta_filetypes
|
from calibre.ebooks.metadata.cli import option_parser as metaop, filetypes as meta_filetypes
|
||||||
@ -636,7 +638,7 @@ class PostInstall:
|
|||||||
self.task_failed('Setting up completion failed')
|
self.task_failed('Setting up completion failed')
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def setup_desktop_integration(self): # {{{
|
def setup_desktop_integration(self): # {{{
|
||||||
try:
|
try:
|
||||||
self.info('Setting up desktop integration...')
|
self.info('Setting up desktop integration...')
|
||||||
|
|
||||||
@ -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())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user