mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Add helper functions for export levels
This commit is contained in:
parent
fb81d1b6f3
commit
eb63f89b1f
1 changed files with 30 additions and 1 deletions
|
@ -28,7 +28,7 @@ from cloudinary.api import delete_resources_by_tag
|
||||||
from cloudinary.uploader import upload
|
from cloudinary.uploader import upload
|
||||||
from cloudinary.utils import cloudinary_url
|
from cloudinary.utils import cloudinary_url
|
||||||
import datetime
|
import datetime
|
||||||
from functools import wraps
|
from functools import reduce, wraps
|
||||||
import hashlib
|
import hashlib
|
||||||
import imghdr
|
import imghdr
|
||||||
from future.moves.itertools import islice, zip_longest
|
from future.moves.itertools import islice, zip_longest
|
||||||
|
@ -38,6 +38,7 @@ import ipwhois.utils
|
||||||
from IPy import IP
|
from IPy import IP
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
|
import operator
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
@ -1263,6 +1264,34 @@ def flatten_tree(obj, key=''):
|
||||||
return new_rows
|
return new_rows
|
||||||
|
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/14692747
|
||||||
|
def get_by_path(root, items):
|
||||||
|
"""Access a nested object in root by item sequence."""
|
||||||
|
return reduce(operator.getitem, items, root)
|
||||||
|
|
||||||
|
|
||||||
|
def set_by_path(root, items, value):
|
||||||
|
"""Set a value in a nested object in root by item sequence."""
|
||||||
|
get_by_path(root, items[:-1])[items[-1]] = value
|
||||||
|
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/7205107
|
||||||
|
def dict_merge(a, b, path=None):
|
||||||
|
if path is None:
|
||||||
|
path = []
|
||||||
|
for key in b:
|
||||||
|
if key in a:
|
||||||
|
if isinstance(a[key], dict) and isinstance(b[key], dict):
|
||||||
|
dict_merge(a[key], b[key], path + [str(key)])
|
||||||
|
elif a[key] == b[key]:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
a[key] = b[key]
|
||||||
|
return a
|
||||||
|
|
||||||
|
|
||||||
def page(endpoint, *args, **kwargs):
|
def page(endpoint, *args, **kwargs):
|
||||||
endpoints = {
|
endpoints = {
|
||||||
'pms_image_proxy': pms_image_proxy,
|
'pms_image_proxy': pms_image_proxy,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue