Skip to content

Commit

Permalink
add a GitlabObject.pretty_print method
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed May 18, 2013
1 parent bc9d440 commit abf1b0d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gitlab.py
Expand Up @@ -448,6 +448,23 @@ def __init__(self, gl, data=None, **kwargs):
def __str__(self):
return '%s => %s' % (type(self), str(self.__dict__))

def pretty_print(self, depth=0):
print "%sid: %s" % (" " * depth * 2, self.id)
for k in sorted(self.__dict__.keys()):
if k == "id":
continue
v = self.__dict__[k]
if isinstance(v, GitlabObject):
if depth == 0:
print "%s:" % k
v.pretty_print(1)
else:
print "%s: %s" % (k, v.id)
else:
if isinstance(v, Gitlab):
continue
print "%s%s: %s" % (" " * depth * 2, k, v)

def json(self):
return json.dumps(self.__dict__, cls=jsonEncoder)

Expand Down

0 comments on commit abf1b0d

Please sign in to comment.