@@ -26,87 +26,90 @@ class Repository(GitHubCore):
2626def __init__ (self ,repo ,session = None ):
2727super (Repository ,self ).__init__ (repo ,session )
2828#: URL used to clone via HTTPS.
29- self .clone_url = repo .get ('clone_url' )
29+ self .clone_url = repo .get ('clone_url' , '' )
3030#: ``datetime`` object representing when the Repository was created.
3131self .created_at = self ._strptime (repo .get ('created_at' ))
3232#: Description of the repository.
33- self .description = repo .get ('description' )
33+ self .description = repo .get ('description' , '' )
3434
3535# The number of forks
3636#: The number of forks made of this repository.
37- self .forks = repo .get ('forks' )
37+ self .forks = repo .get ('forks' , 0 )
3838
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' )
4141
4242# Clone url using git, e.g. git://github.com/sigmavirus24/github3.py
4343#: 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' )
4851
4952# e.g. https://sigmavirus24.github.com/github3.py
5053#: URL of the home page for the project.
51- self .homepage = repo .get ('homepage' )
54+ self .homepage = repo .get ('homepage' , '' )
5255
5356# e.g. https://github.com/sigmavirus24/github3.py
5457#: URL of the project at GitHub.
55- self .html_url = repo .get ('html_url' )
58+ self .html_url = repo .get ('html_url' , '' )
5659#: Unique id of the repository.
57- self .id = repo .get ('id' )
60+ self .id = repo .get ('id' , 0 )
5861#: Language property.
59- self .language = repo .get ('language' )
62+ self .language = repo .get ('language' , '' )
6063#: Mirror property.
61- self .mirror_url = repo .get ('mirror_url' )
64+ self .mirror_url = repo .get ('mirror_url' , '' )
6265
6366# Repository name, e.g. github3.py
6467#: Name of the repository.
65- self .name = repo .get ('name' )
68+ self .name = repo .get ('name' , '' )
6669
6770# Number of open issues
6871#: Number of open issues on the repository.
69- self .open_issues = repo .get ('open_issues' )
72+ self .open_issues = repo .get ('open_issues' , 0 )
7073
7174# Repository owner's name
7275#: :class:`User <github3.users.User>` object representing the
7376# repository owner.
74- self .owner = User (repo .get ('owner' ),self ._session )
77+ self .owner = User (repo .get ('owner' , {} ),self ._session )
7578
76- # Is this repository private?
77- self ._priv = repo .get ('private' )
79+ #: Is this repository private?
80+ self .private = repo .get ('private' )
7881#: ``datetime`` object representing the last time commits were pushed
7982# to the repository.
8083self .pushed_at = self ._strptime (repo .get ('pushed_at' ))
8184#: Size of the repository.
82- self .size = repo .get ('size' )
85+ self .size = repo .get ('size' , 0 )
8386
8487# SSH url e.g. git@github.com/sigmavirus24/github3.py
8588#: URL to clone the repository via SSH.
86- self .ssh_url = repo .get ('ssh_url' )
89+ self .ssh_url = repo .get ('ssh_url' , '' )
8790#: 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' , '' )
8992#: ``datetime`` object representing the last time the repository was
9093# updated.
9194self .updated_at = self ._strptime (repo .get ('updated_at' ))
9295self ._api = repo .get ('url' ,'' )
9396
9497# The number of watchers
9598#: Number of users watching the repository.
96- self .watchers = repo .get ('watchers' )
99+ self .watchers = repo .get ('watchers' , 0 )
97100
98101#: Parent of this fork, if it exists :class;`Repository`
99- self .source = repo .get ('source' , None )
102+ self .source = repo .get ('source' )
100103if self .source :
101104self .source = Repository (self .source ,self )
102105
103106#: Parent of this fork, if it exists :class:`Repository`
104- self .parent = repo .get ('parent' , None )
107+ self .parent = repo .get ('parent' )
105108if self .parent :
106109self .parent = Repository (self .parent ,self )
107110
108111#: default branch for the repository
109- self .master_branch = repo .get ('master_branch' )
112+ self .master_branch = repo .get ('master_branch' , '' )
110113
111114def __repr__ (self ):
112115return '<Repository [{0}/{1}]>' .format (self .owner .login ,self .name )
@@ -692,14 +695,14 @@ def is_fork(self):
692695
693696 :returns: bool
694697 """
695- return self ._is_fork
698+ return self .fork
696699
697700def is_private (self ):
698701"""Checks if this repository is private.
699702
700703 :returns: bool
701704 """
702- return self ._priv
705+ return self .private
703706
704707def git_commit (self ,sha ):
705708"""Get a single (git) commit.
@@ -712,27 +715,6 @@ def git_commit(self, sha):
712715json = self ._json (self ._get (url ),200 )
713716return Commit (json ,self )if json else None
714717
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-
736718@requires_auth
737719def hook (self ,id_num ):
738720"""Get a single hook.
@@ -1359,11 +1341,11 @@ def __init__(self, content):
13591341
13601342# should always be 'base64'
13611343#: Returns encoding used on the content.
1362- self .encoding = content .get ('encoding' )
1344+ self .encoding = content .get ('encoding' , '' )
13631345
13641346# content, base64 encoded and decoded
13651347#: Base64-encoded content of the file.
1366- self .content = content .get ('content' )
1348+ self .content = content .get ('content' , '' )
13671349
13681350#: Decoded content of the file.
13691351self .decoded = self .content
@@ -1372,17 +1354,17 @@ def __init__(self, content):
13721354
13731355# file name, path, and size
13741356#: Name of the content.
1375- self .name = content .get ('name' )
1357+ self .name = content .get ('name' , '' )
13761358#: Path to the content.
1377- self .path = content .get ('path' )
1359+ self .path = content .get ('path' , '' )
13781360#: Size of the content
1379- self .size = content .get ('size' )
1361+ self .size = content .get ('size' , 0 )
13801362#: SHA string.
1381- self .sha = content .get ('sha' )
1363+ self .sha = content .get ('sha' , '' )
13821364
13831365# should always be 'file'
13841366#: Type of content.
1385- self .type = content .get ('type' )
1367+ self .type = content .get ('type' , '' )
13861368
13871369def __repr__ (self ):
13881370return '<Content [{0}]>' .format (self .path )
@@ -1407,19 +1389,19 @@ def __init__(self, download, session=None):
14071389super (Download ,self ).__init__ (download ,session )
14081390self ._api = download .get ('url' ,'' )
14091391#: URL of the download at GitHub.
1410- self .html_url = download .get ('html_url' )
1392+ self .html_url = download .get ('html_url' , '' )
14111393#: Unique id of the download on GitHub.
1412- self .id = download .get ('id' )
1394+ self .id = download .get ('id' , 0 )
14131395#: Name of the download.
1414- self .name = download .get ('name' )
1396+ self .name = download .get ('name' , '' )
14151397#: Description of the download.
1416- self .description = download .get ('description' )
1398+ self .description = download .get ('description' , '' )
14171399#: Size of the download.
1418- self .size = download .get ('size' )
1400+ self .size = download .get ('size' , 0 )
14191401#: 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 )
14211403#: Content type of the download.
1422- self .content_type = download .get ('content_type' )
1404+ self .content_type = download .get ('content_type' , '' )
14231405
14241406def __repr__ (self ):
14251407return '<Download [{0}]>' .format (self .name )
@@ -1473,7 +1455,8 @@ def __init__(self, hook, session=None):
14731455self .name = hook .get ('name' )
14741456#: Events which trigger the hook.
14751457self .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' )
14771460#: Dictionary containing the configuration for the Hook.
14781461self .config = hook .get ('config' )
14791462#: Unique id of the hook.
@@ -1543,7 +1526,7 @@ def is_active(self):
15431526
15441527 :returns: bool
15451528 """
1546- return self ._active
1529+ return self .active
15471530
15481531@requires_auth
15491532def test (self ):