mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Skip formatting bad parameters in notification text
This commit is contained in:
parent
89d1a5782a
commit
ce2982d948
1 changed files with 14 additions and 1 deletions
|
@ -1435,6 +1435,10 @@ def get_themoviedb_info(rating_key=None, media_type=None, themoviedb_id=None):
|
|||
|
||||
|
||||
class CustomFormatter(Formatter):
|
||||
def __init__(self, default='{{{0}}}', default_format_spec='{{{0}:{1}}}'):
|
||||
self.default = default
|
||||
self.default_format_spec = default_format_spec
|
||||
|
||||
def convert_field(self, value, conversion):
|
||||
if conversion is None:
|
||||
return value
|
||||
|
@ -1463,4 +1467,13 @@ class CustomFormatter(Formatter):
|
|||
else:
|
||||
return value
|
||||
else:
|
||||
return super(CustomFormatter, self).format_field(value, format_spec)
|
||||
try:
|
||||
return super(CustomFormatter, self).format_field(value, format_spec)
|
||||
except ValueError:
|
||||
return self.default_format_spec.format(value[1:-1], format_spec)
|
||||
|
||||
def get_value(self, key, args, kwargs):
|
||||
if isinstance(key, basestring):
|
||||
return kwargs.get(key, self.default.format(key))
|
||||
else:
|
||||
return super(CustomFormatter, self).get_value(key, args, kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue