Skip to content

Commit 7175772

Browse files
author
Gauvain Pocentek
committed
id attr might not available
1 parent 5a20efb commit 7175772

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gitlab.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class GitlabObject(object):
396396
requiredGetAttrs = []
397397
requiredCreateAttrs = []
398398
optionalCreateAttrs = []
399+
idAttr = 'id'
399400

400401
@classmethod
401402
def list(cls, gl, **kwargs):
@@ -486,7 +487,8 @@ def __str__(self):
486487
return '%s => %s' % (type(self), str(self.__dict__))
487488

488489
def pretty_print(self, depth=0):
489-
print("%sid: %s" % (" " * depth * 2, self.id))
490+
id = self.__dict__[self.idAttr]
491+
print("%sid: %s" % (" " * depth * 2, id))
490492
for k in sorted(self.__dict__.keys()):
491493
if k == "id":
492494
continue
@@ -562,6 +564,7 @@ class Issue(GitlabObject):
562564

563565
class ProjectBranch(GitlabObject):
564566
_url = '/projects/%(project_id)s/repository/branches'
567+
idAttr = 'name'
565568
canDelete = False
566569
canUpdate = False
567570
canCreate = False

0 commit comments

Comments
 (0)