mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Add custom body line to formatted email
This commit is contained in:
parent
f12de78370
commit
4aeafdae2d
7 changed files with 59 additions and 22 deletions
|
@ -1345,13 +1345,13 @@ class CustomFormatter(Formatter):
|
|||
|
||||
def format_field(self, value, format_spec):
|
||||
if format_spec.startswith('[') and format_spec.endswith(']'):
|
||||
pattern = re.compile(r'\[(\d*):?(\d*)\]')
|
||||
pattern = re.compile(r'\[(-?\d*):?(-?\d*)\]')
|
||||
if re.match(pattern, format_spec): # slice
|
||||
items = [x.strip() for x in unicode(value).split(',')]
|
||||
slice_start, slice_end = re.search(pattern, format_spec).groups()
|
||||
slice_start = max(int(slice_start), 0) if slice_start else None
|
||||
slice_end = min(int(slice_end), len(items)) if slice_end else None
|
||||
return ', '.join(items[slice_start:slice_end])
|
||||
slice_start = helpers.cast_to_int(slice_start) or None
|
||||
slice_end = helpers.cast_to_int(slice_end) or None
|
||||
return ', '.join(items[slice(slice_start, slice_end)])
|
||||
else:
|
||||
return value
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue