mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
no need undersore, keyword arguments None value
This commit is contained in:
parent
13b744328b
commit
56e482aeb1
@ -889,21 +889,16 @@ class FormatterFuncsCaller():
|
|||||||
|
|
||||||
formatter = self.__formatter__
|
formatter = self.__formatter__
|
||||||
func_name = None
|
func_name = None
|
||||||
undersore = None
|
|
||||||
if name.endswith('_') and name[:-1] in formatter.funcs: #given the priority to the backup name
|
if name.endswith('_') and name[:-1] in formatter.funcs: #given the priority to the backup name
|
||||||
func_name = name[:-1]
|
func_name = name[:-1]
|
||||||
undersore = True
|
|
||||||
if not func_name and name in formatter.funcs:
|
if not func_name and name in formatter.funcs:
|
||||||
func_name = name
|
func_name = name
|
||||||
undersore = False
|
|
||||||
|
|
||||||
if func_name:
|
if func_name:
|
||||||
def call(*args, **kargs):
|
def call(*args, **kargs):
|
||||||
args = [str(a) for a in args]
|
args = [str(a) for a in args]
|
||||||
kargs = {k:str(v) for k,v in kargs.items()}
|
kargs = {k:str(v if v else '') for k,v in kargs.items()}
|
||||||
|
|
||||||
def u():
|
|
||||||
return '_' if undersore else ''
|
|
||||||
def raise_error(msg):
|
def raise_error(msg):
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
def raise_mixed(args, kargs):
|
def raise_mixed(args, kargs):
|
||||||
@ -954,7 +949,7 @@ class FormatterFuncsCaller():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Change the error message to return this used name on the template
|
# Change the error message to return this used name on the template
|
||||||
e = e.__class__(_('Error in the function {0} :: {1}').format(
|
e = e.__class__(_('Error in the function {0} :: {1}').format(
|
||||||
func_name+u(),
|
name,
|
||||||
re.sub(r'\w+\.evaluate\(\)\s*', '', str(e), 1))) # remove UserFunction.evaluate() | Builtin*.evaluate()
|
re.sub(r'\w+\.evaluate\(\)\s*', '', str(e), 1))) # remove UserFunction.evaluate() | Builtin*.evaluate()
|
||||||
e.is_internal = True
|
e.is_internal = True
|
||||||
raise e
|
raise e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user