diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2013-06-29 16:34:21 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2013-06-29 16:34:21 +0200 |
commit | 05ab4732ceaee7d6d6c1f162b5925602b7c9ad44 (patch) | |
tree | a606d387588cdb107ac9cc6c624f2f5eef9c37ed /gitlab.py | |
parent | 53562b33fdb1726644c939b78f5445b558c5952e (diff) | |
download | gitlab-05ab4732ceaee7d6d6c1f162b5925602b7c9ad44.tar.gz |
improve pretty_print()
Diffstat (limited to 'gitlab.py')
-rw-r--r-- | gitlab.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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): |