mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 21:21:15 -07:00
Fix notification CustomFormatter for Python 3
This commit is contained in:
parent
e06210f21c
commit
1c56d9c513
1 changed files with 22 additions and 3 deletions
|
@ -1750,6 +1750,23 @@ class CustomFormatter(Formatter):
|
||||||
# this is some markup, find the object and do
|
# this is some markup, find the object and do
|
||||||
# the formatting
|
# the formatting
|
||||||
|
|
||||||
|
# handle arg indexing when empty field_names are given.
|
||||||
|
if field_name == '':
|
||||||
|
if auto_arg_index is False:
|
||||||
|
raise ValueError('cannot switch from manual field '
|
||||||
|
'specification to automatic field '
|
||||||
|
'numbering')
|
||||||
|
field_name = str(auto_arg_index)
|
||||||
|
auto_arg_index += 1
|
||||||
|
elif field_name.isdigit():
|
||||||
|
if auto_arg_index:
|
||||||
|
raise ValueError('cannot switch from manual field '
|
||||||
|
'specification to automatic field '
|
||||||
|
'numbering')
|
||||||
|
# disable auto arg incrementing, if it gets
|
||||||
|
# used later on, then an exception will be raised
|
||||||
|
auto_arg_index = False
|
||||||
|
|
||||||
# given the field_name, find the object it references
|
# given the field_name, find the object it references
|
||||||
# and the argument it came from
|
# and the argument it came from
|
||||||
obj, arg_used = self.get_field(field_name, args, kwargs)
|
obj, arg_used = self.get_field(field_name, args, kwargs)
|
||||||
|
@ -1759,8 +1776,10 @@ class CustomFormatter(Formatter):
|
||||||
obj = self.convert_field(obj, conversion)
|
obj = self.convert_field(obj, conversion)
|
||||||
|
|
||||||
# expand the format spec, if needed
|
# expand the format spec, if needed
|
||||||
format_spec = self._vformat(format_spec, args, kwargs,
|
format_spec, auto_arg_index = self._vformat(
|
||||||
used_args, recursion_depth - 1)
|
format_spec, args, kwargs,
|
||||||
|
used_args, recursion_depth-1,
|
||||||
|
auto_arg_index=auto_arg_index)
|
||||||
|
|
||||||
# format the object and append to the result
|
# format the object and append to the result
|
||||||
formatted_field = self.format_field(obj, format_spec)
|
formatted_field = self.format_field(obj, format_spec)
|
||||||
|
@ -1772,4 +1791,4 @@ class CustomFormatter(Formatter):
|
||||||
result.append(suffix)
|
result.append(suffix)
|
||||||
# result.append(self.format_field(obj, format_spec))
|
# result.append(self.format_field(obj, format_spec))
|
||||||
|
|
||||||
return ''.join(result)
|
return ''.join(result), auto_arg_index
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue