@@ -26,87 +26,90 @@ class Repository(GitHubCore):
26
26
def __init__ (self ,repo ,session = None ):
27
27
super (Repository ,self ).__init__ (repo ,session )
28
28
#: URL used to clone via HTTPS.
29
- self .clone_url = repo .get ('clone_url' )
29
+ self .clone_url = repo .get ('clone_url' , '' )
30
30
#: ``datetime`` object representing when the Repository was created.
31
31
self .created_at = self ._strptime (repo .get ('created_at' ))
32
32
#: Description of the repository.
33
- self .description = repo .get ('description' )
33
+ self .description = repo .get ('description' , '' )
34
34
35
35
# The number of forks
36
36
#: The number of forks made of this repository.
37
- self .forks = repo .get ('forks' )
37
+ self .forks = repo .get ('forks' , 0 )
38
38
39
- # Is this repository a fork?
40
- self ._is_fork = repo .get ('fork' )
39
+ #: Is this repository a fork?
40
+ self .fork = repo .get ('fork' )
41
41
42
42
# Clone url using git, e.g. git://github.com/sigmavirus24/github3.py
43
43
#: Plain git url for an anonymous clone.
44
- self .git_url = repo .get ('git_url' )
45
- self ._has_dl = repo .get ('has_downloads' )
46
- self ._has_issues = repo .get ('has_issues' )
47
- self ._has_wiki = repo .get ('has_wiki' )
44
+ self .git_url = repo .get ('git_url' ,'' )
45
+ #: Whether or not this repository has downloads enabled
46
+ self .has_downloads = repo .get ('has_downloads' )
47
+ #: Whether or not this repository has an issue tracker
48
+ self .has_issues = repo .get ('has_issues' )
49
+ #: Whether or not this repository has the wiki enabled
50
+ self .has_wiki = repo .get ('has_wiki' )
48
51
49
52
# e.g. https://sigmavirus24.github.com/github3.py
50
53
#: URL of the home page for the project.
51
- self .homepage = repo .get ('homepage' )
54
+ self .homepage = repo .get ('homepage' , '' )
52
55
53
56
# e.g. https://github.com/sigmavirus24/github3.py
54
57
#: URL of the project at GitHub.
55
- self .html_url = repo .get ('html_url' )
58
+ self .html_url = repo .get ('html_url' , '' )
56
59
#: Unique id of the repository.
57
- self .id = repo .get ('id' )
60
+ self .id = repo .get ('id' , 0 )
58
61
#: Language property.
59
- self .language = repo .get ('language' )
62
+ self .language = repo .get ('language' , '' )
60
63
#: Mirror property.
61
- self .mirror_url = repo .get ('mirror_url' )
64
+ self .mirror_url = repo .get ('mirror_url' , '' )
62
65
63
66
# Repository name, e.g. github3.py
64
67
#: Name of the repository.
65
- self .name = repo .get ('name' )
68
+ self .name = repo .get ('name' , '' )
66
69
67
70
# Number of open issues
68
71
#: Number of open issues on the repository.
69
- self .open_issues = repo .get ('open_issues' )
72
+ self .open_issues = repo .get ('open_issues' , 0 )
70
73
71
74
# Repository owner's name
72
75
#: :class:`User <github3.users.User>` object representing the
73
76
# repository owner.
74
- self .owner = User (repo .get ('owner' ),self ._session )
77
+ self .owner = User (repo .get ('owner' , {} ),self ._session )
75
78
76
- # Is this repository private?
77
- self ._priv = repo .get ('private' )
79
+ #: Is this repository private?
80
+ self .private = repo .get ('private' )
78
81
#: ``datetime`` object representing the last time commits were pushed
79
82
# to the repository.
80
83
self .pushed_at = self ._strptime (repo .get ('pushed_at' ))
81
84
#: Size of the repository.
82
- self .size = repo .get ('size' )
85
+ self .size = repo .get ('size' , 0 )
83
86
84
87
# SSH url e.g. git@github.com/sigmavirus24/github3.py
85
88
#: URL to clone the repository via SSH.
86
- self .ssh_url = repo .get ('ssh_url' )
89
+ self .ssh_url = repo .get ('ssh_url' , '' )
87
90
#: If it exists, url to clone the repository via SVN.
88
- self .svn_url = repo .get ('svn_url' )
91
+ self .svn_url = repo .get ('svn_url' , '' )
89
92
#: ``datetime`` object representing the last time the repository was
90
93
# updated.
91
94
self .updated_at = self ._strptime (repo .get ('updated_at' ))
92
95
self ._api = repo .get ('url' ,'' )
93
96
94
97
# The number of watchers
95
98
#: Number of users watching the repository.
96
- self .watchers = repo .get ('watchers' )
99
+ self .watchers = repo .get ('watchers' , 0 )
97
100
98
101
#: Parent of this fork, if it exists :class;`Repository`
99
- self .source = repo .get ('source' , None )
102
+ self .source = repo .get ('source' )
100
103
if self .source :
101
104
self .source = Repository (self .source ,self )
102
105
103
106
#: Parent of this fork, if it exists :class:`Repository`
104
- self .parent = repo .get ('parent' , None )
107
+ self .parent = repo .get ('parent' )
105
108
if self .parent :
106
109
self .parent = Repository (self .parent ,self )
107
110
108
111
#: default branch for the repository
109
- self .master_branch = repo .get ('master_branch' )
112
+ self .master_branch = repo .get ('master_branch' , '' )
110
113
111
114
def __repr__ (self ):
112
115
return '<Repository [{0}/{1}]>' .format (self .owner .login ,self .name )
@@ -692,14 +695,14 @@ def is_fork(self):
692
695
693
696
:returns: bool
694
697
"""
695
- return self ._is_fork
698
+ return self .fork
696
699
697
700
def is_private (self ):
698
701
"""Checks if this repository is private.
699
702
700
703
:returns: bool
701
704
"""
702
- return self ._priv
705
+ return self .private
703
706
704
707
def git_commit (self ,sha ):
705
708
"""Get a single (git) commit.
@@ -712,27 +715,6 @@ def git_commit(self, sha):
712
715
json = self ._json (self ._get (url ),200 )
713
716
return Commit (json ,self )if json else None
714
717
715
- def has_downloads (self ):
716
- """Checks if this repository has downloads.
717
-
718
- :returns: bool
719
- """
720
- return self ._has_dl
721
-
722
- def has_issues (self ):
723
- """Checks if this repository has issues enabled.
724
-
725
- :returns: bool
726
- """
727
- return self ._has_issues
728
-
729
- def has_wiki (self ):
730
- """Checks if this repository has a wiki.
731
-
732
- :returns: bool
733
- """
734
- return self ._has_wiki
735
-
736
718
@requires_auth
737
719
def hook (self ,id_num ):
738
720
"""Get a single hook.
@@ -1359,11 +1341,11 @@ def __init__(self, content):
1359
1341
1360
1342
# should always be 'base64'
1361
1343
#: Returns encoding used on the content.
1362
- self .encoding = content .get ('encoding' )
1344
+ self .encoding = content .get ('encoding' , '' )
1363
1345
1364
1346
# content, base64 encoded and decoded
1365
1347
#: Base64-encoded content of the file.
1366
- self .content = content .get ('content' )
1348
+ self .content = content .get ('content' , '' )
1367
1349
1368
1350
#: Decoded content of the file.
1369
1351
self .decoded = self .content
@@ -1372,17 +1354,17 @@ def __init__(self, content):
1372
1354
1373
1355
# file name, path, and size
1374
1356
#: Name of the content.
1375
- self .name = content .get ('name' )
1357
+ self .name = content .get ('name' , '' )
1376
1358
#: Path to the content.
1377
- self .path = content .get ('path' )
1359
+ self .path = content .get ('path' , '' )
1378
1360
#: Size of the content
1379
- self .size = content .get ('size' )
1361
+ self .size = content .get ('size' , 0 )
1380
1362
#: SHA string.
1381
- self .sha = content .get ('sha' )
1363
+ self .sha = content .get ('sha' , '' )
1382
1364
1383
1365
# should always be 'file'
1384
1366
#: Type of content.
1385
- self .type = content .get ('type' )
1367
+ self .type = content .get ('type' , '' )
1386
1368
1387
1369
def __repr__ (self ):
1388
1370
return '<Content [{0}]>' .format (self .path )
@@ -1407,19 +1389,19 @@ def __init__(self, download, session=None):
1407
1389
super (Download ,self ).__init__ (download ,session )
1408
1390
self ._api = download .get ('url' ,'' )
1409
1391
#: URL of the download at GitHub.
1410
- self .html_url = download .get ('html_url' )
1392
+ self .html_url = download .get ('html_url' , '' )
1411
1393
#: Unique id of the download on GitHub.
1412
- self .id = download .get ('id' )
1394
+ self .id = download .get ('id' , 0 )
1413
1395
#: Name of the download.
1414
- self .name = download .get ('name' )
1396
+ self .name = download .get ('name' , '' )
1415
1397
#: Description of the download.
1416
- self .description = download .get ('description' )
1398
+ self .description = download .get ('description' , '' )
1417
1399
#: Size of the download.
1418
- self .size = download .get ('size' )
1400
+ self .size = download .get ('size' , 0 )
1419
1401
#: How many times this particular file has been downloaded.
1420
- self .download_count = download .get ('download_count' )
1402
+ self .download_count = download .get ('download_count' , 0 )
1421
1403
#: Content type of the download.
1422
- self .content_type = download .get ('content_type' )
1404
+ self .content_type = download .get ('content_type' , '' )
1423
1405
1424
1406
def __repr__ (self ):
1425
1407
return '<Download [{0}]>' .format (self .name )
@@ -1473,7 +1455,8 @@ def __init__(self, hook, session=None):
1473
1455
self .name = hook .get ('name' )
1474
1456
#: Events which trigger the hook.
1475
1457
self .events = hook .get ('events' )
1476
- self ._active = hook .get ('active' )
1458
+ #: Whether or not this Hook is marked as active on GitHub
1459
+ self .active = hook .get ('active' )
1477
1460
#: Dictionary containing the configuration for the Hook.
1478
1461
self .config = hook .get ('config' )
1479
1462
#: Unique id of the hook.
@@ -1543,7 +1526,7 @@ def is_active(self):
1543
1526
1544
1527
:returns: bool
1545
1528
"""
1546
- return self ._active
1529
+ return self .active
1547
1530
1548
1531
@requires_auth
1549
1532
def test (self ):