forked from PyGithub/PyGithub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepository.py
More file actions
1131 lines (1034 loc) · 44 KB
/
Copy pathRepository.py
File metadata and controls
1131 lines (1034 loc) · 44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# WARNING: this file is generated automaticaly.
# Do not modify it manually, your work would be lost.
# Copyright 2012 Vincent Jacques
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import urllib
import datetime
import GithubObject
import PaginatedList
import Branch
import IssueEvent
import Label
import InputGitAuthor
import GitBlob
import Organization
import GitRef
import Issue
import Repository
import PullRequest
import RepositoryKey
import NamedUser
import Milestone
import InputGitTreeElement
import Comparison
import CommitComment
import GitCommit
import Team
import Commit
import GitTree
import Hook
import Tag
import GitTag
import Download
import Permissions
import Event
class Repository( GithubObject.GithubObject ):
@property
def clone_url( self ):
self._completeIfNotSet( self._clone_url )
return self._NoneIfNotSet( self._clone_url )
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
@property
def description( self ):
self._completeIfNotSet( self._description )
return self._NoneIfNotSet( self._description )
@property
def fork( self ):
self._completeIfNotSet( self._fork )
return self._NoneIfNotSet( self._fork )
@property
def forks( self ):
self._completeIfNotSet( self._forks )
return self._NoneIfNotSet( self._forks )
@property
def full_name( self ):
self._completeIfNotSet( self._full_name )
return self._NoneIfNotSet( self._full_name )
@property
def git_url( self ):
self._completeIfNotSet( self._git_url )
return self._NoneIfNotSet( self._git_url )
@property
def has_downloads( self ):
self._completeIfNotSet( self._has_downloads )
return self._NoneIfNotSet( self._has_downloads )
@property
def has_issues( self ):
self._completeIfNotSet( self._has_issues )
return self._NoneIfNotSet( self._has_issues )
@property
def has_wiki( self ):
self._completeIfNotSet( self._has_wiki )
return self._NoneIfNotSet( self._has_wiki )
@property
def homepage( self ):
self._completeIfNotSet( self._homepage )
return self._NoneIfNotSet( self._homepage )
@property
def html_url( self ):
self._completeIfNotSet( self._html_url )
return self._NoneIfNotSet( self._html_url )
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
@property
def language( self ):
self._completeIfNotSet( self._language )
return self._NoneIfNotSet( self._language )
@property
def master_branch( self ):
self._completeIfNotSet( self._master_branch )
return self._NoneIfNotSet( self._master_branch )
@property
def name( self ):
self._completeIfNotSet( self._name )
return self._NoneIfNotSet( self._name )
@property
def open_issues( self ):
self._completeIfNotSet( self._open_issues )
return self._NoneIfNotSet( self._open_issues )
@property
def organization( self ):
self._completeIfNotSet( self._organization )
return self._NoneIfNotSet( self._organization )
@property
def owner( self ):
self._completeIfNotSet( self._owner )
return self._NoneIfNotSet( self._owner )
@property
def parent( self ):
self._completeIfNotSet( self._parent )
return self._NoneIfNotSet( self._parent )
@property
def permissions( self ):
self._completeIfNotSet( self._permissions )
return self._NoneIfNotSet( self._permissions )
@property
def private( self ):
self._completeIfNotSet( self._private )
return self._NoneIfNotSet( self._private )
@property
def pushed_at( self ):
self._completeIfNotSet( self._pushed_at )
return self._NoneIfNotSet( self._pushed_at )
@property
def size( self ):
self._completeIfNotSet( self._size )
return self._NoneIfNotSet( self._size )
@property
def source( self ):
self._completeIfNotSet( self._source )
return self._NoneIfNotSet( self._source )
@property
def ssh_url( self ):
self._completeIfNotSet( self._ssh_url )
return self._NoneIfNotSet( self._ssh_url )
@property
def svn_url( self ):
self._completeIfNotSet( self._svn_url )
return self._NoneIfNotSet( self._svn_url )
@property
def updated_at( self ):
self._completeIfNotSet( self._updated_at )
return self._NoneIfNotSet( self._updated_at )
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
@property
def watchers( self ):
self._completeIfNotSet( self._watchers )
return self._NoneIfNotSet( self._watchers )
def add_to_collaborators( self, collaborator ):
assert isinstance( collaborator, NamedUser.NamedUser ), collaborator
headers, data = self._requester.requestAndCheck(
"PUT",
self.url + "/collaborators/" + collaborator._identity,
None,
None
)
def compare( self, base, head ):
assert isinstance( base, ( str, unicode ) ), base
assert isinstance( head, ( str, unicode ) ), head
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/compare/" + base + "..." + head,
None,
None
)
return Comparison.Comparison( self._requester, data, completed = True )
def create_download( self, name, size, description = GithubObject.NotSet, content_type = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert isinstance( size, int ), size
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert content_type is GithubObject.NotSet or isinstance( content_type, ( str, unicode ) ), content_type
post_parameters = {
"name": name,
"size": size,
}
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
if content_type is not GithubObject.NotSet:
post_parameters[ "content_type" ] = content_type
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/downloads",
None,
post_parameters
)
return Download.Download( self._requester, data, completed = True )
def create_git_blob( self, content, encoding ):
assert isinstance( content, ( str, unicode ) ), content
assert isinstance( encoding, ( str, unicode ) ), encoding
post_parameters = {
"content": content,
"encoding": encoding,
}
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/git/blobs",
None,
post_parameters
)
return GitBlob.GitBlob( self._requester, data, completed = True )
def create_git_commit( self, message, tree, parents, author = GithubObject.NotSet, committer = GithubObject.NotSet ):
assert isinstance( message, ( str, unicode ) ), message
assert isinstance( tree, GitTree.GitTree ), tree
assert all( isinstance( element, GitCommit.GitCommit ) for element in parents ), parents
assert author is GithubObject.NotSet or isinstance( author, InputGitAuthor.InputGitAuthor ), author
assert committer is GithubObject.NotSet or isinstance( committer, InputGitAuthor.InputGitAuthor ), committer
post_parameters = {
"message": message,
"tree": tree._identity,
"parents": [ element._identity for element in parents ],
}
if author is not GithubObject.NotSet:
post_parameters[ "author" ] = author._identity
if committer is not GithubObject.NotSet:
post_parameters[ "committer" ] = committer._identity
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/git/commits",
None,
post_parameters
)
return GitCommit.GitCommit( self._requester, data, completed = True )
def create_git_ref( self, ref, sha ):
assert isinstance( ref, ( str, unicode ) ), ref
assert isinstance( sha, ( str, unicode ) ), sha
post_parameters = {
"ref": ref,
"sha": sha,
}
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/git/refs",
None,
post_parameters
)
return GitRef.GitRef( self._requester, data, completed = True )
def create_git_tag( self, tag, message, object, type, tagger = GithubObject.NotSet ):
assert isinstance( tag, ( str, unicode ) ), tag
assert isinstance( message, ( str, unicode ) ), message
assert isinstance( object, ( str, unicode ) ), object
assert isinstance( type, ( str, unicode ) ), type
assert tagger is GithubObject.NotSet or isinstance( tagger, InputGitAuthor.InputGitAuthor ), tagger
post_parameters = {
"tag": tag,
"message": message,
"object": object,
"type": type,
}
if tagger is not GithubObject.NotSet:
post_parameters[ "tagger" ] = tagger._identity
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/git/tags",
None,
post_parameters
)
return GitTag.GitTag( self._requester, data, completed = True )
def create_git_tree( self, tree, base_tree = GithubObject.NotSet ):
assert all( isinstance( element, InputGitTreeElement.InputGitTreeElement ) for element in tree ), tree
assert base_tree is GithubObject.NotSet or isinstance( base_tree, GitTree.GitTree ), base_tree
post_parameters = {
"tree": [ element._identity for element in tree ],
}
if base_tree is not GithubObject.NotSet:
post_parameters[ "base_tree" ] = base_tree._identity
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/git/trees",
None,
post_parameters
)
return GitTree.GitTree( self._requester, data, completed = True )
def create_hook( self, name, config, events = GithubObject.NotSet, active = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert isinstance( config, dict ), config
assert events is GithubObject.NotSet or all( isinstance( element, ( str, unicode ) ) for element in events ), events
assert active is GithubObject.NotSet or isinstance( active, bool ), active
post_parameters = {
"name": name,
"config": config,
}
if events is not GithubObject.NotSet:
post_parameters[ "events" ] = events
if active is not GithubObject.NotSet:
post_parameters[ "active" ] = active
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/hooks",
None,
post_parameters
)
return Hook.Hook( self._requester, data, completed = True )
def create_issue( self, title, body = GithubObject.NotSet, assignee = GithubObject.NotSet, milestone = GithubObject.NotSet, labels = GithubObject.NotSet ):
assert isinstance( title, ( str, unicode ) ), title
assert body is GithubObject.NotSet or isinstance( body, ( str, unicode ) ), body
assert assignee is GithubObject.NotSet or isinstance( assignee, NamedUser.NamedUser ), assignee
assert milestone is GithubObject.NotSet or isinstance( milestone, Milestone.Milestone ), milestone
assert labels is GithubObject.NotSet or all( isinstance( element, Label.Label ) for element in labels ), labels
post_parameters = {
"title": title,
}
if body is not GithubObject.NotSet:
post_parameters[ "body" ] = body
if assignee is not GithubObject.NotSet:
post_parameters[ "assignee" ] = assignee._identity
if milestone is not GithubObject.NotSet:
post_parameters[ "milestone" ] = milestone._identity
if labels is not GithubObject.NotSet:
post_parameters[ "labels" ] = [ element._identity for element in labels ]
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/issues",
None,
post_parameters
)
return Issue.Issue( self._requester, data, completed = True )
def create_key( self, title, key ):
assert isinstance( title, ( str, unicode ) ), title
assert isinstance( key, ( str, unicode ) ), key
post_parameters = {
"title": title,
"key": key,
}
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/keys",
None,
post_parameters
)
return RepositoryKey.RepositoryKey( self._requester, data, completed = True, repoUrl = self._url )
def create_label( self, name, color ):
assert isinstance( name, ( str, unicode ) ), name
assert isinstance( color, ( str, unicode ) ), color
post_parameters = {
"name": name,
"color": color,
}
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/labels",
None,
post_parameters
)
return Label.Label( self._requester, data, completed = True )
def create_milestone( self, title, state = GithubObject.NotSet, description = GithubObject.NotSet, due_on = GithubObject.NotSet ):
assert isinstance( title, ( str, unicode ) ), title
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert due_on is GithubObject.NotSet or isinstance( due_on, datetime.date ), due_on
post_parameters = {
"title": title,
}
if state is not GithubObject.NotSet:
post_parameters[ "state" ] = state
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
if due_on is not GithubObject.NotSet:
post_parameters[ "due_on" ] = due_on.strftime( "%Y-%m-%d" )
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/milestones",
None,
post_parameters
)
return Milestone.Milestone( self._requester, data, completed = True )
def create_pull( self, *args, **kwds ):
if len( args ) + len( kwds ) == 4:
return self.__create_pull_1( *args, **kwds )
else:
return self.__create_pull_2( *args, **kwds )
def __create_pull_1( self, title, body, base, head ):
assert isinstance( title, ( str, unicode ) ), title
assert isinstance( body, ( str, unicode ) ), body
assert isinstance( base, ( str, unicode ) ), base
assert isinstance( head, ( str, unicode ) ), head
return self.__create_pull( title = title, body = body, base = base, head = head )
def __create_pull_2( self, issue, base, head ):
assert isinstance( issue, Issue.Issue ), issue
assert isinstance( base, ( str, unicode ) ), base
assert isinstance( head, ( str, unicode ) ), head
return self.__create_pull( issue = issue._identity, base = base, head = head )
def __create_pull( self, **kwds ):
post_parameters = kwds
headers, data = self._requester.requestAndCheck(
"POST",
self.url + "/pulls",
None,
post_parameters
)
return PullRequest.PullRequest( self._requester, data, completed = True )
def edit( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, public = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet ):
assert isinstance( name, ( str, unicode ) ), name
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert homepage is GithubObject.NotSet or isinstance( homepage, ( str, unicode ) ), homepage
assert public is GithubObject.NotSet or isinstance( public, bool ), public
assert has_issues is GithubObject.NotSet or isinstance( has_issues, bool ), has_issues
assert has_wiki is GithubObject.NotSet or isinstance( has_wiki, bool ), has_wiki
assert has_downloads is GithubObject.NotSet or isinstance( has_downloads, bool ), has_downloads
post_parameters = {
"name": name,
}
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
if homepage is not GithubObject.NotSet:
post_parameters[ "homepage" ] = homepage
if public is not GithubObject.NotSet:
post_parameters[ "public" ] = public
if has_issues is not GithubObject.NotSet:
post_parameters[ "has_issues" ] = has_issues
if has_wiki is not GithubObject.NotSet:
post_parameters[ "has_wiki" ] = has_wiki
if has_downloads is not GithubObject.NotSet:
post_parameters[ "has_downloads" ] = has_downloads
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
def get_branches( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/branches",
None,
None
)
return PaginatedList.PaginatedList(
Branch.Branch,
self._requester,
headers,
data
)
def get_collaborators( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/collaborators",
None,
None
)
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
headers,
data
)
def get_comment( self, id ):
assert isinstance( id, int ), id
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/comments/" + str( id ),
None,
None
)
return CommitComment.CommitComment( self._requester, data, completed = True )
def get_comments( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/comments",
None,
None
)
return PaginatedList.PaginatedList(
CommitComment.CommitComment,
self._requester,
headers,
data
)
def get_commit( self, sha ):
assert isinstance( sha, ( str, unicode ) ), sha
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/commits/" + sha,
None,
None
)
return Commit.Commit( self._requester, data, completed = True )
def get_commits( self, sha = GithubObject.NotSet, path = GithubObject.NotSet ):
assert sha is GithubObject.NotSet or isinstance( sha, ( str, unicode ) ), sha
assert path is GithubObject.NotSet or isinstance( path, ( str, unicode ) ), path
url_parameters = dict()
if sha is not GithubObject.NotSet:
url_parameters[ "sha" ] = sha
if path is not GithubObject.NotSet:
url_parameters[ "path" ] = path
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/commits",
url_parameters,
None
)
return PaginatedList.PaginatedList(
Commit.Commit,
self._requester,
headers,
data
)
def get_contributors( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/contributors",
None,
None
)
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
headers,
data
)
def get_download( self, id ):
assert isinstance( id, int ), id
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/downloads/" + str( id ),
None,
None
)
return Download.Download( self._requester, data, completed = True )
def get_downloads( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/downloads",
None,
None
)
return PaginatedList.PaginatedList(
Download.Download,
self._requester,
headers,
data
)
def get_events( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/events",
None,
None
)
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
headers,
data
)
def get_forks( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/forks",
None,
None
)
return PaginatedList.PaginatedList(
Repository,
self._requester,
headers,
data
)
def get_git_blob( self, sha ):
assert isinstance( sha, ( str, unicode ) ), sha
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/git/blobs/" + sha,
None,
None
)
return GitBlob.GitBlob( self._requester, data, completed = True )
def get_git_commit( self, sha ):
assert isinstance( sha, ( str, unicode ) ), sha
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/git/commits/" + sha,
None,
None
)
return GitCommit.GitCommit( self._requester, data, completed = True )
def get_git_ref( self, ref ):
assert isinstance( ref, ( str, unicode ) ), ref
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/git/" + ref,
None,
None
)
return GitRef.GitRef( self._requester, data, completed = True )
def get_git_refs( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/git/refs",
None,
None
)
return PaginatedList.PaginatedList(
GitRef.GitRef,
self._requester,
headers,
data
)
def get_git_tag( self, sha ):
assert isinstance( sha, ( str, unicode ) ), sha
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/git/tags/" + sha,
None,
None
)
return GitTag.GitTag( self._requester, data, completed = True )
def get_git_tree( self, sha, recursive = GithubObject.NotSet ):
assert isinstance( sha, ( str, unicode ) ), sha
assert recursive is GithubObject.NotSet or isinstance( recursive, bool ), recursive
url_parameters = dict()
if recursive is not GithubObject.NotSet:
url_parameters[ "recursive" ] = recursive
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/git/trees/" + sha,
url_parameters,
None
)
return GitTree.GitTree( self._requester, data, completed = True )
def get_hook( self, id ):
assert isinstance( id, int ), id
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/hooks/" + str( id ),
None,
None
)
return Hook.Hook( self._requester, data, completed = True )
def get_hooks( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/hooks",
None,
None
)
return PaginatedList.PaginatedList(
Hook.Hook,
self._requester,
headers,
data
)
def get_issue( self, number ):
assert isinstance( number, int ), number
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/issues/" + str( number ),
None,
None
)
return Issue.Issue( self._requester, data, completed = True )
def get_issues( self, milestone = GithubObject.NotSet, state = GithubObject.NotSet, assignee = GithubObject.NotSet, mentioned = GithubObject.NotSet, labels = GithubObject.NotSet, sort = GithubObject.NotSet, direction = GithubObject.NotSet, since = GithubObject.NotSet ):
assert milestone is GithubObject.NotSet or milestone == "*" or milestone == "none" or isinstance( milestone, Milestone.Milestone ), milestone
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
assert assignee is GithubObject.NotSet or assignee == "*" or assignee == "none" or isinstance( assignee, NamedUser.NamedUser ), assignee
assert mentioned is GithubObject.NotSet or isinstance( mentioned, NamedUser.NamedUser ), mentioned
assert labels is GithubObject.NotSet or all( isinstance( element, Label.Label ) for element in labels ), labels
assert sort is GithubObject.NotSet or isinstance( sort, ( str, unicode ) ), sort
assert direction is GithubObject.NotSet or isinstance( direction, ( str, unicode ) ), direction
assert since is GithubObject.NotSet or isinstance( since, datetime.datetime ), since
url_parameters = dict()
if milestone is not GithubObject.NotSet:
if isinstance( milestone, str ):
url_parameters[ "milestone" ] = milestone
else:
url_parameters[ "milestone" ] = milestone._identity
if state is not GithubObject.NotSet:
url_parameters[ "state" ] = state
if assignee is not GithubObject.NotSet:
if isinstance( assignee, str ):
url_parameters[ "assignee" ] = assignee
else:
url_parameters[ "assignee" ] = assignee._identity
if mentioned is not GithubObject.NotSet:
url_parameters[ "mentioned" ] = mentioned._identity
if labels is not GithubObject.NotSet:
url_parameters[ "labels" ] = ",".join( label._identity for label in labels )
if sort is not GithubObject.NotSet:
url_parameters[ "sort" ] = sort
if direction is not GithubObject.NotSet:
url_parameters[ "direction" ] = direction
if since is not GithubObject.NotSet:
url_parameters[ "since" ] = since.strftime( "%Y-%m-%dT%H:%M:%SZ" )
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/issues",
url_parameters,
None
)
return PaginatedList.PaginatedList(
Issue.Issue,
self._requester,
headers,
data
)
def get_issues_event( self, id ):
assert isinstance( id, int ), id
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/issues/events/" + str( id ),
None,
None
)
return IssueEvent.IssueEvent( self._requester, data, completed = True )
def get_issues_events( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/issues/events",
None,
None
)
return PaginatedList.PaginatedList(
IssueEvent.IssueEvent,
self._requester,
headers,
data
)
def get_key( self, id ):
assert isinstance( id, int ), id
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/keys/" + str( id ),
None,
None
)
return RepositoryKey.RepositoryKey( self._requester, data, completed = True, repoUrl = self._url )
def get_keys( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/keys",
None,
None
)
return PaginatedList.PaginatedList(
lambda requester, data, completed: RepositoryKey.RepositoryKey( requester, data, completed, repoUrl = self._url ),
self._requester,
headers,
data
)
def get_label( self, name ):
assert isinstance( name, ( str, unicode ) ), name
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/labels/" + urllib.quote( name ),
None,
None
)
return Label.Label( self._requester, data, completed = True )
def get_labels( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/labels",
None,
None
)
return PaginatedList.PaginatedList(
Label.Label,
self._requester,
headers,
data
)
def get_languages( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/languages",
None,
None
)
return data
def get_milestone( self, number ):
assert isinstance( number, int ), number
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/milestones/" + str( number ),
None,
None
)
return Milestone.Milestone( self._requester, data, completed = True )
def get_milestones( self, state = GithubObject.NotSet, sort = GithubObject.NotSet, direction = GithubObject.NotSet ):
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
assert sort is GithubObject.NotSet or isinstance( sort, ( str, unicode ) ), sort
assert direction is GithubObject.NotSet or isinstance( direction, ( str, unicode ) ), direction
url_parameters = dict()
if state is not GithubObject.NotSet:
url_parameters[ "state" ] = state
if sort is not GithubObject.NotSet:
url_parameters[ "sort" ] = sort
if direction is not GithubObject.NotSet:
url_parameters[ "direction" ] = direction
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/milestones",
url_parameters,
None
)
return PaginatedList.PaginatedList(
Milestone.Milestone,
self._requester,
headers,
data
)
def get_network_events( self ):
headers, data = self._requester.requestAndCheck(
"GET",
"https://api.github.com/networks/" + self.owner.login + "/" + self.name + "/events",
None,
None
)
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
headers,
data
)
def get_pull( self, number ):
assert isinstance( number, int ), number
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/pulls/" + str( number ),
None,
None
)
return PullRequest.PullRequest( self._requester, data, completed = True )
def get_pulls( self, state = GithubObject.NotSet ):
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
url_parameters = dict()
if state is not GithubObject.NotSet:
url_parameters[ "state" ] = state
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/pulls",
url_parameters,
None
)
return PaginatedList.PaginatedList(
PullRequest.PullRequest,
self._requester,
headers,
data
)
def get_tags( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/tags",
None,
None
)
return PaginatedList.PaginatedList(
Tag.Tag,
self._requester,
headers,
data
)
def get_teams( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/teams",
None,
None
)
return PaginatedList.PaginatedList(
Team.Team,
self._requester,
headers,
data
)
def get_watchers( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/watchers",
None,
None
)
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
headers,
data
)
def has_in_collaborators( self, collaborator ):
assert isinstance( collaborator, NamedUser.NamedUser ), collaborator
status, headers, data = self._requester.requestRaw(
"GET",
self.url + "/collaborators/" + collaborator._identity,
None,
None
)
return status == 204
def remove_from_collaborators( self, collaborator ):
assert isinstance( collaborator, NamedUser.NamedUser ), collaborator
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url + "/collaborators/" + collaborator._identity,