mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
a3ac32b48a
commit
f328f4d8eb
@ -20,6 +20,7 @@ from calibre.utils.localization import canonicalize_lang
|
||||
readonly = False
|
||||
version = 0 # change this if you change signature of implementation()
|
||||
|
||||
|
||||
def to_stream(data):
|
||||
ans = BytesIO(data[1])
|
||||
ans.name = data[0]
|
||||
|
@ -25,6 +25,7 @@ from calibre.utils.localization import calibre_langcode_to_name
|
||||
def bool_sort_key(bools_are_tristate):
|
||||
return (lambda x:{True: 1, False: 2, None: 3}.get(x, 3)) if bools_are_tristate else lambda x:{True: 1, False: 2, None: 2}.get(x, 2)
|
||||
|
||||
|
||||
IDENTITY = lambda x: x
|
||||
|
||||
|
||||
@ -756,4 +757,3 @@ def create_field(name, table, bools_are_tristate, get_template_functions):
|
||||
elif table.metadata['datatype'] == 'series':
|
||||
cls = SeriesField
|
||||
return cls(name, table, bools_are_tristate, get_template_functions)
|
||||
|
||||
|
@ -1451,15 +1451,15 @@ class KOBOTOUCH(KOBO):
|
||||
|
||||
def open_linux(self):
|
||||
super(KOBOTOUCH, self).open_linux()
|
||||
|
||||
|
||||
self.swap_drives_if_needed()
|
||||
|
||||
def open_osx(self):
|
||||
# Just dump some info to the logs.
|
||||
super(KOBOTOUCH, self).open_osx()
|
||||
|
||||
# Wrap some debugging output in a try/except so that it unlikely to break things completely.
|
||||
try:
|
||||
# Wrap some debugging output in a try/except so that it unlikely to break things completely.
|
||||
try:
|
||||
if DEBUG:
|
||||
from calibre.constants import plugins
|
||||
usbobserver, usbobserver_err = plugins['usbobserver']
|
||||
|
@ -12,8 +12,7 @@ import re, string, traceback
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import DEBUG
|
||||
from calibre.utils.formatter_functions import formatter_functions, compile_user_function
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.formatter_functions import formatter_functions
|
||||
|
||||
|
||||
class _Parser(object):
|
||||
@ -174,6 +173,7 @@ class _Parser(object):
|
||||
else:
|
||||
self.error(_('expression is not function or constant'))
|
||||
|
||||
|
||||
class TemplateFormatter(string.Formatter):
|
||||
'''
|
||||
Provides a format function that substitutes '' for any missing value
|
||||
|
@ -1635,6 +1635,7 @@ class UserFunction(FormatterUserFunction):
|
||||
cls = locals_['UserFunction'](name, doc, arg_count, eval_func)
|
||||
return cls
|
||||
|
||||
|
||||
def compile_user_template_functions(funcs):
|
||||
compiled_funcs = {}
|
||||
for func in funcs:
|
||||
@ -1653,6 +1654,7 @@ def compile_user_template_functions(funcs):
|
||||
traceback.print_exc()
|
||||
return compiled_funcs
|
||||
|
||||
|
||||
def load_user_template_functions(library_uuid, funcs, precompiled_user_functions=None):
|
||||
unload_user_template_functions(library_uuid)
|
||||
if precompiled_user_functions:
|
||||
@ -1661,5 +1663,6 @@ def load_user_template_functions(library_uuid, funcs, precompiled_user_functions
|
||||
compiled_funcs = compile_user_template_functions(funcs)
|
||||
formatter_functions().register_functions(library_uuid, compiled_funcs.values())
|
||||
|
||||
|
||||
def unload_user_template_functions(library_uuid):
|
||||
formatter_functions().unregister_functions(library_uuid)
|
||||
|
Loading…
x
Reference in New Issue
Block a user