@@ -397,6 +397,7 @@ class GitlabObject(object):
397
397
requiredCreateAttrs = []
398
398
optionalCreateAttrs = []
399
399
idAttr = 'id'
400
+ shortPrintAttr = None
400
401
401
402
@classmethod
402
403
def list (cls , gl , ** kwargs ):
@@ -486,6 +487,14 @@ def __init__(self, gl, data=None, **kwargs):
486
487
def __str__ (self ):
487
488
return '%s => %s' % (type (self ), str (self .__dict__ ))
488
489
490
+ def short_print (self , depth = 0 ):
491
+ id = self .__dict__ [self .idAttr ]
492
+ print ("%s%s: %s" % (" " * depth * 2 , self .idAttr , id ))
493
+ if self .shortPrintAttr :
494
+ print ("%s%s: %s" % (" " * depth * 2 ,
495
+ self .shortPrintAttr .replace ('_' , '-' ),
496
+ self .__dict__ [self .shortPrintAttr ]))
497
+
489
498
def pretty_print (self , depth = 0 ):
490
499
id = self .__dict__ [self .idAttr ]
491
500
print ("%s%s: %s" % (" " * depth * 2 , self .idAttr , id ))
@@ -511,6 +520,7 @@ def json(self):
511
520
512
521
class User (GitlabObject ):
513
522
_url = '/users'
523
+ shortPrintAttr = 'username'
514
524
requiredCreateAttrs = ['email' , 'password' , 'username' , 'name' ]
515
525
optionalCreateAttrs = ['skype' , 'linkedin' , 'twitter' , 'projects_limit' ,
516
526
'extern_uid' , 'provider' , 'bio' ]
@@ -539,6 +549,7 @@ class Group(GitlabObject):
539
549
_url = '/groups'
540
550
_constructorTypes = {'projects' : 'Project' }
541
551
requiredCreateAttrs = ['name' , 'path' ]
552
+ shortPrintAttr = 'name'
542
553
543
554
def transfer_project (self , id ):
544
555
url = '/groups/%d/projects/%d?private_token=%s' % \
@@ -551,6 +562,7 @@ def transfer_project(self, id):
551
562
class Hook (GitlabObject ):
552
563
_url = '/hooks'
553
564
requiredCreateAttrs = ['url' ]
565
+ shortPrintAttr = 'url'
554
566
555
567
556
568
class Issue (GitlabObject ):
@@ -561,6 +573,7 @@ class Issue(GitlabObject):
561
573
canDelete = False
562
574
canUpdate = False
563
575
canCreate = False
576
+ shortPrintAttr = 'title'
564
577
565
578
566
579
class ProjectBranch (GitlabObject ):
@@ -599,6 +612,7 @@ class ProjectCommit(GitlabObject):
599
612
canUpdate = False
600
613
canCreate = False
601
614
requiredListAttrs = ['project_id' ]
615
+ shortPrintAttr = 'title'
602
616
603
617
604
618
class ProjectKey (GitlabObject ):
@@ -614,6 +628,7 @@ class ProjectHook(GitlabObject):
614
628
requiredListAttrs = ['project_id' ]
615
629
requiredGetAttrs = ['project_id' ]
616
630
requiredCreateAttrs = ['project_id' , 'url' ]
631
+ shortPrintAttr = 'url'
617
632
618
633
619
634
class ProjectIssueNote (GitlabObject ):
@@ -636,6 +651,7 @@ class ProjectIssue(GitlabObject):
636
651
requiredCreateAttrs = ['project_id' , 'title' ]
637
652
optionalCreateAttrs = ['description' , 'assignee_id' , 'milestone_id' ,
638
653
'labels' ]
654
+ shortPrintAttr = 'title'
639
655
640
656
def Note (self , id = None , ** kwargs ):
641
657
return self ._getListOrObject (ProjectIssueNote , id ,
@@ -650,6 +666,7 @@ class ProjectMember(GitlabObject):
650
666
requiredListAttrs = ['project_id' ]
651
667
requiredGetAttrs = ['project_id' ]
652
668
requiredCreateAttrs = ['project_id' , 'user_id' , 'access_level' ]
669
+ shortPrintAttr = 'username'
653
670
654
671
655
672
class ProjectNote (GitlabObject ):
@@ -664,11 +681,13 @@ class ProjectNote(GitlabObject):
664
681
665
682
class ProjectTag (GitlabObject ):
666
683
_url = '/projects/%(project_id)s/repository/tags'
684
+ idAttr = 'name'
667
685
canGet = False
668
686
canDelete = False
669
687
canUpdate = False
670
688
canCreate = False
671
689
requiredListAttrs = ['project_id' ]
690
+ shortPrintAttr = 'name'
672
691
673
692
674
693
class ProjectMergeRequestNote (GitlabObject ):
@@ -704,6 +723,7 @@ class ProjectMilestone(GitlabObject):
704
723
requiredGetAttrs = ['project_id' ]
705
724
requiredCreateAttrs = ['project_id' , 'title' ]
706
725
optionalCreateAttrs = ['description' , 'due_date' ]
726
+ shortPrintAttr = 'title'
707
727
708
728
709
729
class ProjectSnippetNote (GitlabObject ):
@@ -723,6 +743,7 @@ class ProjectSnippet(GitlabObject):
723
743
requiredGetAttrs = ['project_id' ]
724
744
requiredCreateAttrs = ['project_id' , 'title' , 'file_name' , 'code' ]
725
745
optionalCreateAttrs = ['lifetime' ]
746
+ shortPrintAttr = 'title'
726
747
727
748
def Content (self ):
728
749
url = "/projects/%(project_id)s/snippets/%(snippet_id)s/raw" % \
@@ -750,6 +771,7 @@ class Project(GitlabObject):
750
771
optionalCreateAttrs = ['default_branch' , 'issues_enabled' , 'wall_enabled' ,
751
772
'merge_requests_enabled' , 'wiki_enabled' ,
752
773
'namespace_id' ]
774
+ shortPrintAttr = 'path'
753
775
754
776
def Branch (self , id = None , ** kwargs ):
755
777
return self ._getListOrObject (ProjectBranch , id ,
0 commit comments