mirror of
https://github.com/Mailu/Mailu.git
synced 2025-06-06 23:36:26 +02:00
Convert OrderedDict to dict for output
This commit is contained in:
parent
68caf50154
commit
3937986e76
@ -7,7 +7,7 @@ import socket
|
|||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from collections import Counter
|
from collections import Counter, OrderedDict
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@ -396,11 +396,19 @@ def config_import(verbose=0, secrets=False, quiet=False, color=False, update=Fal
|
|||||||
return chain(message, changes)
|
return chain(message, changes)
|
||||||
|
|
||||||
def log(action, target, message=None):
|
def log(action, target, message=None):
|
||||||
|
|
||||||
|
def od2d(val):
|
||||||
|
""" converts OrderedDicts to Dict for logging purposes """
|
||||||
|
if isinstance(val, OrderedDict):
|
||||||
|
return {k: od2d(v) for k, v in val.items()}
|
||||||
|
elif isinstance(val, list):
|
||||||
|
return [od2d(v) for v in val]
|
||||||
|
else:
|
||||||
|
return val
|
||||||
|
|
||||||
if message is None:
|
if message is None:
|
||||||
# TODO: convert nested OrderedDict to dict
|
|
||||||
# see: flask mailu config-import -nvv yaml/dump4.yaml
|
|
||||||
try:
|
try:
|
||||||
message = dict(logger[target.__class__].dump(target))
|
message = od2d(logger[target.__class__].dump(target))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
message = target
|
message = target
|
||||||
if not isinstance(message, str):
|
if not isinstance(message, str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user