summaryrefslogtreecommitdiff
path: root/gitlab.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2013-06-29 16:34:21 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2013-06-29 16:34:21 +0200
commit05ab4732ceaee7d6d6c1f162b5925602b7c9ad44 (patch)
treea606d387588cdb107ac9cc6c624f2f5eef9c37ed /gitlab.py
parent53562b33fdb1726644c939b78f5445b558c5952e (diff)
downloadgitlab-05ab4732ceaee7d6d6c1f162b5925602b7c9ad44.tar.gz
improve pretty_print()
Diffstat (limited to 'gitlab.py')
-rw-r--r--gitlab.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/gitlab.py b/gitlab.py
index 9419627..7177178 100644
--- a/gitlab.py
+++ b/gitlab.py
@@ -504,6 +504,17 @@ class GitlabObject(object):
self.shortPrintAttr.replace('_', '-'),
self.__dict__[self.shortPrintAttr]))
+ @staticmethod
+ def _obj_to_str(obj):
+ if isinstance(obj, dict):
+ s = ", ".join(["%s: %s" % (x, GitlabObject._obj_to_str(y)) for (x, y) in obj.items()])
+ return "{ %s }" % s
+ elif isinstance(obj, list):
+ s = ", ".join([GitlabObject._obj_to_str(x) for x in obj])
+ return "[ %s ]" %s
+ else:
+ return str(obj)
+
def pretty_print(self, depth=0):
id = self.__dict__[self.idAttr]
print("%s%s: %s" % (" " * depth * 2, self.idAttr, id))
@@ -521,6 +532,7 @@ class GitlabObject(object):
else:
if isinstance(v, Gitlab):
continue
+ v = GitlabObject._obj_to_str(v)
print("%s%s: %s" % (" " * depth * 2, pretty_k, v))
def json(self):