mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] try to improve lisibility a bit
This commit is contained in:
parent
17ca60c3a5
commit
93cb77d0a5
1 changed files with 18 additions and 14 deletions
|
@ -717,22 +717,26 @@ def _append_to_stats(stats, monitor, statics=[]):
|
|||
statics = [statics]
|
||||
|
||||
# Appending function
|
||||
def _append(s, m, st):
|
||||
for k, v in m.items():
|
||||
if k in st:
|
||||
s[k] = v
|
||||
elif isinstance(v, dict):
|
||||
if k not in s:
|
||||
s[k] = {}
|
||||
s[k] = _append(s[k], v, st)
|
||||
def _append(_stats, _monitor, _statics):
|
||||
for key, value in _monitor.items():
|
||||
if key in _statics:
|
||||
_stats[key] = value
|
||||
|
||||
elif isinstance(value, dict):
|
||||
if key not in _stats:
|
||||
_stats[key] = {}
|
||||
_stats[key] = _append(_stats[key], value, _statics)
|
||||
|
||||
else:
|
||||
if k not in s:
|
||||
s[k] = []
|
||||
if isinstance(v, list):
|
||||
s[k].extend(v)
|
||||
if key not in _stats:
|
||||
_stats[key] = []
|
||||
|
||||
if isinstance(value, list):
|
||||
_stats[key].extend(value)
|
||||
else:
|
||||
s[k].append(v)
|
||||
return s
|
||||
_stats[key].append(value)
|
||||
|
||||
return _stats
|
||||
|
||||
stats = _append(stats, monitor, statics)
|
||||
return stats
|
||||
|
|
Loading…
Add table
Reference in a new issue