mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Add ability for custom calculated attributes for exporting
This commit is contained in:
parent
55100dfb7a
commit
d3704fcee6
1 changed files with 11 additions and 2 deletions
|
@ -1172,10 +1172,16 @@ def get_attrs_to_dict(obj, attrs):
|
|||
d = {}
|
||||
|
||||
for attr, sub in attrs.items():
|
||||
no_attr = False
|
||||
|
||||
if isinstance(obj, dict):
|
||||
value = obj.get(attr, None)
|
||||
else:
|
||||
value = getattr(obj, attr, None)
|
||||
try:
|
||||
value = getattr(obj, attr)
|
||||
except AttributeError:
|
||||
no_attr = True
|
||||
value = None
|
||||
|
||||
if callable(value):
|
||||
value = value()
|
||||
|
@ -1194,7 +1200,10 @@ def get_attrs_to_dict(obj, attrs):
|
|||
if isinstance(value, list):
|
||||
value = [sub(o) for o in value]
|
||||
else:
|
||||
value = sub(value)
|
||||
if no_attr:
|
||||
value = sub(obj)
|
||||
else:
|
||||
value = sub(value)
|
||||
|
||||
d[attr] = value
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue