mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[fix] Review pretty_print_dict to prevent encoding issue
This commit is contained in:
parent
90bd495096
commit
66ed5dfd8d
1 changed files with 8 additions and 6 deletions
|
@ -54,21 +54,23 @@ def pretty_print_dict(d, depth=0):
|
|||
if isinstance(v, list) and len(v) == 1:
|
||||
v = v[0]
|
||||
if isinstance(v, dict):
|
||||
print((" ") * depth + ("%s: " % str(k)))
|
||||
print("{:s}{}: ".format(" " * depth, k))
|
||||
pretty_print_dict(v, depth+1)
|
||||
elif isinstance(v, list):
|
||||
print((" ") * depth + ("%s: " % str(k)))
|
||||
print("{:s}{}: ".format(" " * depth, k))
|
||||
for key, value in enumerate(v):
|
||||
if isinstance(value, tuple):
|
||||
pretty_print_dict({value[0]: value[1]}, depth+1)
|
||||
elif isinstance(value, dict):
|
||||
pretty_print_dict({key: value}, depth+1)
|
||||
else:
|
||||
print((" ") * (depth+1) + "- " +str(value))
|
||||
if isinstance(value, unicode):
|
||||
value = value.encode('utf-8')
|
||||
print("{:s}- {}".format(" " * (depth+1), value))
|
||||
else:
|
||||
if not isinstance(v, basestring):
|
||||
v = str(v)
|
||||
print((" ") * depth + "%s: %s" % (str(k), v))
|
||||
if isinstance(v, unicode):
|
||||
v = v.encode('utf-8')
|
||||
print("{:s}{}: {}".format(" " * depth, k, v))
|
||||
|
||||
def get_locale():
|
||||
"""Return current user locale"""
|
||||
|
|
Loading…
Add table
Reference in a new issue