Fix some pylint warnings

This commit is contained in:
Benjamin Renard 2021-05-26 14:44:30 +02:00
parent b2d33e3ddf
commit 5bdfc8479d

View file

@ -1,19 +1,25 @@
# -*- coding: utf-8 -*-
""" Some really common helper functions """
#
# Pretty formating helpers
#
def pretty_format_value(value, encoding='utf8'):
""" Returned pretty formated value to display """
if isinstance(value, dict):
return pretty_format_dict(value)
if isinstance(value, list):
return ",".join([pretty_format_value(x) for x in value])
elif isinstance(value, bytes):
if isinstance(value, bytes):
return "'%s'" % value.decode(encoding, errors='replace')
elif isinstance(value, str):
if isinstance(value, str):
return "'%s'" % value
return str(value)
def pretty_format_dict(attrs):
""" Returned pretty formated dict to display """
result = []
for attr in sorted(attrs.keys()):
result.append(" - %s : %s" % (attr, pretty_format_value(attrs[attr])))
@ -21,6 +27,7 @@ def pretty_format_dict(attrs):
def pretty_format_list(row):
""" Returned pretty formated list to display """
result = []
for idx, values in enumerate(row):
result.append(" - #%s : %s" % (idx, pretty_format_value(values)))