mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 04:49:36 -07:00
Add len function to notification expressions
This commit is contained in:
parent
9ca5d81b60
commit
dff9a56950
3 changed files with 9 additions and 0 deletions
|
@ -1929,6 +1929,7 @@ Rating: {rating}/10 --> Rating: /10
|
|||
<li><span class="inline-pre">divmod(a, b)</span></li>
|
||||
<li><span class="inline-pre">float(x)</span></li>
|
||||
<li><span class="inline-pre">int(x)</span></li>
|
||||
<li><span class="inline-pre">len(s)</span></li>
|
||||
<li><span class="inline-pre">round(n[, ndigits])</span></li>
|
||||
<li><span class="inline-pre">str(x)</span></li>
|
||||
</ul>
|
||||
|
|
|
@ -537,6 +537,13 @@ def helper_divmod(a, b):
|
|||
return 0
|
||||
|
||||
|
||||
def helper_len(s):
|
||||
try:
|
||||
return len(s)
|
||||
except (ValueError, TypeError):
|
||||
return 0
|
||||
|
||||
|
||||
def helper_round(n, ndigits=None):
|
||||
try:
|
||||
return round(n, ndigits)
|
||||
|
|
|
@ -1825,6 +1825,7 @@ def str_eval(field_name, kwargs):
|
|||
'divmod': helpers.helper_divmod,
|
||||
'float': helpers.cast_to_float,
|
||||
'int': helpers.cast_to_int,
|
||||
'len': helpers.helper_len,
|
||||
'round': helpers.helper_round,
|
||||
'str': str
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue