From dd0c6e63f4fc4db0f3e6d19888586662a37eb553 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sat, 5 May 2012 19:20:27 +0200 Subject: [PATCH] Fix testEvents --- CodeGenerator/templates/GithubObject.py | 2 +- IntegrationTest.py | 14 +- .../description.000.human_readable.json | 35 +- .../description.001.normalized.json | 317 +++++++++++++++--- JsonDescriptionOfGithubApiV3/normalize.py | 44 ++- ReferenceOfClasses.md | 2 +- github/GithubObjects/AuthenticatedUser.py | 81 +++-- github/GithubObjects/Authorization.py | 18 +- github/GithubObjects/Branch.py | 4 +- github/GithubObjects/Commit.py | 16 +- github/GithubObjects/CommitComment.py | 22 +- github/GithubObjects/Download.py | 40 +-- github/GithubObjects/Event.py | 24 +- github/GithubObjects/Gist.py | 30 +- github/GithubObjects/GistComment.py | 12 +- github/GithubObjects/GitBlob.py | 10 +- github/GithubObjects/GitCommit.py | 14 +- github/GithubObjects/GitRef.py | 6 +- github/GithubObjects/GitTag.py | 12 +- github/GithubObjects/GitTree.py | 8 +- github/GithubObjects/Hook.py | 18 +- github/GithubObjects/Issue.py | 38 +-- github/GithubObjects/IssueComment.py | 12 +- github/GithubObjects/IssueEvent.py | 14 +- github/GithubObjects/Label.py | 6 +- github/GithubObjects/Milestone.py | 20 +- github/GithubObjects/NamedUser.py | 52 +-- github/GithubObjects/Organization.py | 58 ++-- github/GithubObjects/PullRequest.py | 54 +-- github/GithubObjects/PullRequestComment.py | 22 +- github/GithubObjects/PullRequestFile.py | 18 +- github/GithubObjects/Repository.py | 111 +++--- github/GithubObjects/RepositoryKey.py | 8 +- github/GithubObjects/Tag.py | 8 +- github/GithubObjects/Team.py | 24 +- github/GithubObjects/UserKey.py | 8 +- 36 files changed, 721 insertions(+), 461 deletions(-) diff --git a/CodeGenerator/templates/GithubObject.py b/CodeGenerator/templates/GithubObject.py index 1f28c7e0..9874f433 100644 --- a/CodeGenerator/templates/GithubObject.py +++ b/CodeGenerator/templates/GithubObject.py @@ -65,7 +65,7 @@ class {{ class.name }}( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory {% for attribute in class.attributes|dictsort:"name" %} - if "{{ attribute.name }}" in attributes: + if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None: {% if attribute.type.simple %} self.__{{ attribute.name }} = attributes[ "{{ attribute.name }}" ] {% else %} diff --git a/IntegrationTest.py b/IntegrationTest.py index 1ad86065..e4582233 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -345,15 +345,15 @@ class IntegrationTest: self.printList( "Organization events", self.g.get_organization( self.cobayeOrganization ).get_events(), lambda e: e.type ) self.printList( "User events", self.g.get_user().get_events(), lambda e: e.type ) - # o = self.g.get_organization( self.cobayeOrganization ) - # self.printList( "Organization events", self.g.get_user().get_organization_events( o ), lambda e: e.type ) + o = self.g.get_organization( self.cobayeOrganization ) + self.printList( "Organization events", self.g.get_user().get_organization_events( o ), lambda e: e.type ) - # self.printList( "Repo events", self.g.get_user().get_repo( "TestPyGithub" ).get_events(), lambda e: e.type ) - # self.printList( "Repo issues events", self.g.get_user().get_repo( "TestPyGithub" ).get_issues_events(), lambda e: e.event ) - # print self.g.get_user().get_repo( "TestPyGithub" ).get_issues_event( 10693379 ).event - # self.printList( "Repo network events", self.g.get_user().get_repo( "TestPyGithub" ).get_network_events(), lambda e: e.type ) + self.printList( "Repo events", self.g.get_user().get_repo( "TestPyGithub" ).get_events(), lambda e: e.type ) + self.printList( "Repo issues events", self.g.get_user().get_repo( "TestPyGithub" ).get_issues_events(), lambda e: e.event ) + print self.g.get_user().get_repo( "TestPyGithub" ).get_issues_event( 10693379 ).event + self.printList( "Repo network events", self.g.get_user().get_repo( "TestPyGithub" ).get_network_events(), lambda e: e.type ) - # self.printList( "Issue events", self.g.get_user().get_repo( "TestPyGithub" ).get_issue( 23 ).get_events(), lambda e: e.event ) + self.printList( "Issue events", self.g.get_user().get_repo( "TestPyGithub" ).get_issue( 23 ).get_events(), lambda e: e.event ) def testFollow( self ): cobaye = self.g.get_user( self.cobayeUser ) diff --git a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json index 18441118..80a8c7e3 100644 --- a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json +++ b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json @@ -61,7 +61,8 @@ "name": "events", "singular_name": "event", "type": "Event", - "get_list": true + "get_list": true, + "url": [ { "type": "constant", "value": "https://api.github.com/events" } ] }, { "name": "issues", @@ -190,8 +191,18 @@ "group": "events", "type": { "cardinality": "list", "name": "Event" }, "mandatory_parameters": [ - { "name": "org", "type": "@todo" } - ] + { "name": "org", "type": "Organization" } + ], + "request": { + "verb": "GET", + "url": [ + { "type": "constant", "value": "https://api.github.com/users/" }, + { "type": "attribute", "value": [ "login" ] }, + { "type": "constant", "value": "/events/orgs/" }, + { "type": "argument", "value": [ "org", "login" ] } + ], + "information": "status" + } }, { "name": [ "get", "starred", "gists" ], @@ -1345,7 +1356,11 @@ "get_list": true, "get_element": { "parameter": { "name": "id", "type": "@todo" } - } + }, + "url": [ + { "type": "attribute", "value": [ "url" ] }, + { "type": "constant", "value": "/issues/events" } + ] }, { "name": "keys", @@ -1438,7 +1453,17 @@ { "name": [ "get", "network", "events" ], "type": { "cardinality": "list", "name": "Event" }, - "group": "events" + "group": "events", + "request": { + "verb": "GET", + "url": [ + { "type": "constant", "value": "https://api.github.com/networks/" }, + { "type": "attribute", "value": [ "owner", "login" ] }, + { "type": "constant", "value": "/" }, + { "type": "attribute", "value": [ "name" ] }, + { "type": "constant", "value": "/events" } + ] + } }, { "name": [ "get", "languages" ], diff --git a/JsonDescriptionOfGithubApiV3/description.001.normalized.json b/JsonDescriptionOfGithubApiV3/description.001.normalized.json index 439986d8..0ed226ea 100644 --- a/JsonDescriptionOfGithubApiV3/description.001.normalized.json +++ b/JsonDescriptionOfGithubApiV3/description.001.normalized.json @@ -370,7 +370,11 @@ }, { "type": "constant", - "value": "/authorizations/" + "value": "/authorizations" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -430,15 +434,9 @@ ], "request": { "url": [ - { - "type": "attribute", - "value": [ - "url" - ] - }, { "type": "constant", - "value": "/events" + "value": "https://api.github.com/events" } ], "information": "data", @@ -558,7 +556,11 @@ }, { "type": "constant", - "value": "/keys/" + "value": "/keys" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -937,7 +939,11 @@ }, { "type": "constant", - "value": "/watched/" + "value": "/watched" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -1016,7 +1022,11 @@ }, { "type": "constant", - "value": "/watched/" + "value": "/watched" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -1064,7 +1074,11 @@ }, { "type": "constant", - "value": "/watched/" + "value": "/watched" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -1112,7 +1126,11 @@ }, { "type": "constant", - "value": "/following/" + "value": "/following" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -1191,7 +1209,11 @@ }, { "type": "constant", - "value": "/following/" + "value": "/following" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -1239,7 +1261,11 @@ }, { "type": "constant", - "value": "/following/" + "value": "/following" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -1472,9 +1498,9 @@ "mandatory_parameters": [ { "type": { - "simple": true, + "simple": false, "cardinality": "scalar", - "name": "@todo" + "name": "Organization" }, "name": "org" } @@ -1485,6 +1511,33 @@ "organization", "events" ], + "request": { + "url": [ + { + "type": "constant", + "value": "https://api.github.com/users/" + }, + { + "type": "attribute", + "value": [ + "login" + ] + }, + { + "type": "constant", + "value": "/events/orgs/" + }, + { + "type": "argument", + "value": [ + "org", + "login" + ] + } + ], + "information": "status", + "verb": "GET" + }, "optional_parameters": [], "type": { "simple": false, @@ -2588,7 +2641,11 @@ }, { "type": "constant", - "value": "/comments/" + "value": "/comments" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -3616,7 +3673,11 @@ }, { "type": "constant", - "value": "/comments/" + "value": "/comments" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -3812,7 +3873,11 @@ }, { "type": "constant", - "value": "/labels/" + "value": "/labels" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -5356,7 +5421,11 @@ }, { "type": "constant", - "value": "/members/" + "value": "/members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -5404,7 +5473,11 @@ }, { "type": "constant", - "value": "/members/" + "value": "/members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -5452,7 +5525,11 @@ }, { "type": "constant", - "value": "/public_members/" + "value": "/public_members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -5531,7 +5608,11 @@ }, { "type": "constant", - "value": "/public_members/" + "value": "/public_members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -5579,7 +5660,11 @@ }, { "type": "constant", - "value": "/public_members/" + "value": "/public_members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -6240,7 +6325,11 @@ }, { "type": "constant", - "value": "/comments/" + "value": "/comments" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7067,7 +7156,11 @@ }, { "type": "constant", - "value": "/collaborators/" + "value": "/collaborators" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7146,7 +7239,11 @@ }, { "type": "constant", - "value": "/collaborators/" + "value": "/collaborators" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7194,7 +7291,11 @@ }, { "type": "constant", - "value": "/collaborators/" + "value": "/collaborators" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7241,7 +7342,11 @@ }, { "type": "constant", - "value": "/comments/" + "value": "/comments" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7318,7 +7423,11 @@ }, { "type": "constant", - "value": "/commits/" + "value": "/commits" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7509,7 +7618,11 @@ }, { "type": "constant", - "value": "/downloads/" + "value": "/downloads" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7697,7 +7810,11 @@ }, { "type": "constant", - "value": "/git_blobs/" + "value": "/git_blobs" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7817,7 +7934,11 @@ }, { "type": "constant", - "value": "/git_commits/" + "value": "/git_commits" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -7912,7 +8033,11 @@ }, { "type": "constant", - "value": "/git_refs/" + "value": "/git_refs" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8063,7 +8188,11 @@ }, { "type": "constant", - "value": "/git_tags/" + "value": "/git_tags" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8159,7 +8288,11 @@ }, { "type": "constant", - "value": "/git_trees/" + "value": "/git_trees" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8280,7 +8413,11 @@ }, { "type": "constant", - "value": "/hooks/" + "value": "/hooks" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8431,7 +8568,11 @@ }, { "type": "constant", - "value": "/issues/" + "value": "/issues" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8573,7 +8714,11 @@ }, { "type": "constant", - "value": "/issues_events/" + "value": "/issues/events" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8610,7 +8755,7 @@ }, { "type": "constant", - "value": "/issues_events" + "value": "/issues/events" } ], "information": "data", @@ -8699,7 +8844,11 @@ }, { "type": "constant", - "value": "/keys/" + "value": "/keys" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8825,7 +8974,11 @@ }, { "type": "constant", - "value": "/labels/" + "value": "/labels" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -8968,7 +9121,11 @@ }, { "type": "constant", - "value": "/milestones/" + "value": "/milestones" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -9070,7 +9227,11 @@ }, { "type": "constant", - "value": "/pulls/" + "value": "/pulls" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -9231,6 +9392,36 @@ "network", "events" ], + "request": { + "url": [ + { + "type": "constant", + "value": "https://api.github.com/networks/" + }, + { + "type": "attribute", + "value": [ + "owner", + "login" + ] + }, + { + "type": "constant", + "value": "/" + }, + { + "type": "attribute", + "value": [ + "name" + ] + }, + { + "type": "constant", + "value": "/events" + } + ], + "verb": "GET" + }, "optional_parameters": [], "type": { "simple": false, @@ -9585,7 +9776,11 @@ }, { "type": "constant", - "value": "/members/" + "value": "/members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -9664,7 +9859,11 @@ }, { "type": "constant", - "value": "/members/" + "value": "/members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -9712,7 +9911,11 @@ }, { "type": "constant", - "value": "/members/" + "value": "/members" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -9760,7 +9963,11 @@ }, { "type": "constant", - "value": "/repos/" + "value": "/repos" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -9839,7 +10046,11 @@ }, { "type": "constant", - "value": "/repos/" + "value": "/repos" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", @@ -9887,7 +10098,11 @@ }, { "type": "constant", - "value": "/repos/" + "value": "/repos" + }, + { + "type": "constant", + "value": "/" }, { "type": "argument", diff --git a/JsonDescriptionOfGithubApiV3/normalize.py b/JsonDescriptionOfGithubApiV3/normalize.py index 01570ba6..7e2f3120 100644 --- a/JsonDescriptionOfGithubApiV3/normalize.py +++ b/JsonDescriptionOfGithubApiV3/normalize.py @@ -107,7 +107,15 @@ class Function: class Collection: def __init__( self, desc ): - checkKeys( desc, [ "name", "singular_name", "type" ], [ "add_element", "add_several_elements", "create_element", "delete_list", "get_element", "get_list", "has_element", "remove_element", "remove_several_elements", "set_list" ] ) + checkKeys( desc, [ "name", "singular_name", "type" ], [ "add_element", "add_several_elements", "create_element", "delete_list", "get_element", "get_list", "has_element", "remove_element", "remove_several_elements", "set_list", "url" ] ) + + if "url" in desc: + self.__url = desc[ "url" ] + else: + self.__url = [ + { "type": "attribute", "value": [ "url" ] }, + { "type": "constant", "value": "/" + desc[ "name" ] }, + ] name = desc[ "name" ] if isinstance( desc[ "name" ], list ) else [ desc[ "name" ] ] self.methods = list() @@ -118,9 +126,8 @@ class Collection: { "request": { "verb": "PUT", - "url": [ - { "type": "attribute", "value": [ "url" ] }, - { "type": "constant", "value": "/" + desc[ "name" ] + "/" }, + "url": self.__url + [ + { "type": "constant", "value": "/" }, { "type": "argument", "value": [ desc[ "singular_name" ], "_identity" ] }, ], "information": "status", @@ -134,10 +141,7 @@ class Collection: { "request": { "verb": "POST", - "url": [ - { "type": "attribute", "value": [ "url" ] }, - { "type": "constant", "value": "/" + desc[ "name" ] }, - ], + "url": self.__url, "information": "status", "post_parameters": True } @@ -150,7 +154,7 @@ class Collection: { "request": { "verb": "POST", - "url": [ { "type": "attribute", "value": [ "url" ] }, { "type": "constant", "value": "/" + desc[ "name" ] } ], + "url": self.__url, "information": "status", "post_parameters": True, } @@ -179,9 +183,8 @@ class Collection: hack = { "request": { "verb": "GET", - "url": [ - { "type": "attribute", "value": [ "url" ] }, - { "type": "constant", "value": "/" + desc[ "name" ] + "/" }, + "url": self.__url + [ + { "type": "constant", "value": "/" }, { "type": "argument", "value": [ desc[ "get_element" ][ "parameter" ][ "name" ] ] }, ], "information": "data", @@ -200,7 +203,7 @@ class Collection: { "request": { "verb": "GET", - "url": [ { "type": "attribute", "value": [ "url" ] }, { "type": "constant", "value": "/" + desc[ "name" ] } ], + "url": self.__url, "information": "data", } } @@ -212,9 +215,8 @@ class Collection: { "request": { "verb": "GET", - "url": [ - { "type": "attribute", "value": [ "url" ] }, - { "type": "constant", "value": "/" + desc[ "name" ] + "/" }, + "url": self.__url + [ + { "type": "constant", "value": "/" }, { "type": "argument", "value": [ desc[ "singular_name" ], "_identity" ] }, ], "information": "status", @@ -228,9 +230,8 @@ class Collection: { "request": { "verb": "DELETE", - "url": [ - { "type": "attribute", "value": [ "url" ] }, - { "type": "constant", "value": "/" + desc[ "name" ] + "/" }, + "url": self.__url + [ + { "type": "constant", "value": "/" }, { "type": "argument", "value": [ desc[ "singular_name" ], "_identity" ] }, ], "information": "status", @@ -244,10 +245,7 @@ class Collection: { "request": { "verb": "DELETE", - "url": [ - { "type": "attribute", "value": [ "url" ] }, - { "type": "constant", "value": "/" + desc[ "name" ] }, - ], + "url": self.__url, "information": "status", "post_parameters": True } diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index d04fa753..323e73a5 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -62,7 +62,7 @@ Events ------ * `get_events()`: list of `Event` * `get_organization_events( org )`: list of `Event` - * `org` + * `org`: `Organization` Followers --------- diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index 84535acd..431b7bda 100644 --- a/github/GithubObjects/AuthenticatedUser.py +++ b/github/GithubObjects/AuthenticatedUser.py @@ -162,7 +162,7 @@ class AuthenticatedUser( object ): def add_to_following( self, following ): status, headers, data = self.__requester.request( "PUT", - str( self.url ) + "/following/" + str( following._identity ), + str( self.url ) + "/following" + "/" + str( following._identity ), None, None ) @@ -170,7 +170,7 @@ class AuthenticatedUser( object ): def add_to_watched( self, watched ): status, headers, data = self.__requester.request( "PUT", - str( self.url ) + "/watched/" + str( watched._identity ), + str( self.url ) + "/watched" + "/" + str( watched._identity ), None, None ) @@ -283,7 +283,7 @@ class AuthenticatedUser( object ): def get_authorization( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/authorizations/" + str( id ), + str( self.url ) + "/authorizations" + "/" + str( id ), None, None ) @@ -315,7 +315,7 @@ class AuthenticatedUser( object ): def get_events( self ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/events", + "https://api.github.com/events", None, None ) @@ -385,7 +385,7 @@ class AuthenticatedUser( object ): def get_key( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/keys/" + str( id ), + str( self.url ) + "/keys" + "/" + str( id ), None, None ) @@ -406,7 +406,18 @@ class AuthenticatedUser( object ): ) def get_organization_events( self, org ): - pass + status, headers, data = self.__requester.request( + "GET", + "https://api.github.com/users/" + str( self.login ) + "/events/orgs/" + str( org.login ), + None, + None + ) + return PaginatedList.PaginatedList( + Event.Event, + self.__requester, + headers, + data + ) def get_orgs( self ): status, headers, data = self.__requester.request( @@ -465,7 +476,7 @@ class AuthenticatedUser( object ): def has_in_following( self, following ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/following/" + str( following._identity ), + str( self.url ) + "/following" + "/" + str( following._identity ), None, None ) @@ -474,7 +485,7 @@ class AuthenticatedUser( object ): def has_in_watched( self, watched ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/watched/" + str( watched._identity ), + str( self.url ) + "/watched" + "/" + str( watched._identity ), None, None ) @@ -492,7 +503,7 @@ class AuthenticatedUser( object ): def remove_from_following( self, following ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/following/" + str( following._identity ), + str( self.url ) + "/following" + "/" + str( following._identity ), None, None ) @@ -500,7 +511,7 @@ class AuthenticatedUser( object ): def remove_from_watched( self, watched ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/watched/" + str( watched._identity ), + str( self.url ) + "/watched" + "/" + str( watched._identity ), None, None ) @@ -549,53 +560,53 @@ class AuthenticatedUser( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "avatar_url" in attributes: + if "avatar_url" in attributes and attributes[ "avatar_url" ] is not None: self.__avatar_url = attributes[ "avatar_url" ] - if "bio" in attributes: + if "bio" in attributes and attributes[ "bio" ] is not None: self.__bio = attributes[ "bio" ] - if "blog" in attributes: + if "blog" in attributes and attributes[ "blog" ] is not None: self.__blog = attributes[ "blog" ] - if "collaborators" in attributes: + if "collaborators" in attributes and attributes[ "collaborators" ] is not None: self.__collaborators = attributes[ "collaborators" ] - if "company" in attributes: + if "company" in attributes and attributes[ "company" ] is not None: self.__company = attributes[ "company" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "disk_usage" in attributes: + if "disk_usage" in attributes and attributes[ "disk_usage" ] is not None: self.__disk_usage = attributes[ "disk_usage" ] - if "email" in attributes: + if "email" in attributes and attributes[ "email" ] is not None: self.__email = attributes[ "email" ] - if "followers" in attributes: + if "followers" in attributes and attributes[ "followers" ] is not None: self.__followers = attributes[ "followers" ] - if "following" in attributes: + if "following" in attributes and attributes[ "following" ] is not None: self.__following = attributes[ "following" ] - if "gravatar_id" in attributes: + if "gravatar_id" in attributes and attributes[ "gravatar_id" ] is not None: self.__gravatar_id = attributes[ "gravatar_id" ] - if "hireable" in attributes: + if "hireable" in attributes and attributes[ "hireable" ] is not None: self.__hireable = attributes[ "hireable" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "location" in attributes: + if "location" in attributes and attributes[ "location" ] is not None: self.__location = attributes[ "location" ] - if "login" in attributes: + if "login" in attributes and attributes[ "login" ] is not None: self.__login = attributes[ "login" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "owned_private_repos" in attributes: + if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None: self.__owned_private_repos = attributes[ "owned_private_repos" ] - if "plan" in attributes: + if "plan" in attributes and attributes[ "plan" ] is not None: self.__plan = attributes[ "plan" ] - if "private_gists" in attributes: + if "private_gists" in attributes and attributes[ "private_gists" ] is not None: self.__private_gists = attributes[ "private_gists" ] - if "public_gists" in attributes: + if "public_gists" in attributes and attributes[ "public_gists" ] is not None: self.__public_gists = attributes[ "public_gists" ] - if "public_repos" in attributes: + if "public_repos" in attributes and attributes[ "public_repos" ] is not None: self.__public_repos = attributes[ "public_repos" ] - if "total_private_repos" in attributes: + if "total_private_repos" in attributes and attributes[ "total_private_repos" ] is not None: self.__total_private_repos = attributes[ "total_private_repos" ] - if "type" in attributes: + if "type" in attributes and attributes[ "type" ] is not None: self.__type = attributes[ "type" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Authorization.py b/github/GithubObjects/Authorization.py index 97b0a483..6811a9c5 100644 --- a/github/GithubObjects/Authorization.py +++ b/github/GithubObjects/Authorization.py @@ -119,21 +119,21 @@ class Authorization( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "app" in attributes: + if "app" in attributes and attributes[ "app" ] is not None: self.__app = attributes[ "app" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "note" in attributes: + if "note" in attributes and attributes[ "note" ] is not None: self.__note = attributes[ "note" ] - if "note_url" in attributes: + if "note_url" in attributes and attributes[ "note_url" ] is not None: self.__note_url = attributes[ "note_url" ] - if "scopes" in attributes: + if "scopes" in attributes and attributes[ "scopes" ] is not None: self.__scopes = attributes[ "scopes" ] - if "token" in attributes: + if "token" in attributes and attributes[ "token" ] is not None: self.__token = attributes[ "token" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Branch.py b/github/GithubObjects/Branch.py index 07f13df7..e3cd1010 100644 --- a/github/GithubObjects/Branch.py +++ b/github/GithubObjects/Branch.py @@ -49,7 +49,7 @@ class Branch( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "commit" in attributes: + if "commit" in attributes and attributes[ "commit" ] is not None: self.__commit = Commit.Commit( self.__requester, attributes[ "commit" ], lazy = True ) - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] diff --git a/github/GithubObjects/Commit.py b/github/GithubObjects/Commit.py index 7fb6bfa4..1d129600 100644 --- a/github/GithubObjects/Commit.py +++ b/github/GithubObjects/Commit.py @@ -121,19 +121,19 @@ class Commit( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "author" in attributes: + if "author" in attributes and attributes[ "author" ] is not None: self.__author = NamedUser.NamedUser( self.__requester, attributes[ "author" ], lazy = True ) - if "commit" in attributes: + if "commit" in attributes and attributes[ "commit" ] is not None: self.__commit = GitCommit.GitCommit( self.__requester, attributes[ "commit" ], lazy = True ) - if "committer" in attributes: + if "committer" in attributes and attributes[ "committer" ] is not None: self.__committer = NamedUser.NamedUser( self.__requester, attributes[ "committer" ], lazy = True ) - if "files" in attributes: + if "files" in attributes and attributes[ "files" ] is not None: self.__files = attributes[ "files" ] - if "parents" in attributes: + if "parents" in attributes and attributes[ "parents" ] is not None: self.__parents = attributes[ "parents" ] - if "sha" in attributes: + if "sha" in attributes and attributes[ "sha" ] is not None: self.__sha = attributes[ "sha" ] - if "stats" in attributes: + if "stats" in attributes and attributes[ "stats" ] is not None: self.__stats = attributes[ "stats" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/CommitComment.py b/github/GithubObjects/CommitComment.py index d15db258..390e105c 100644 --- a/github/GithubObjects/CommitComment.py +++ b/github/GithubObjects/CommitComment.py @@ -123,25 +123,25 @@ class CommitComment( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "body" in attributes: + if "body" in attributes and attributes[ "body" ] is not None: self.__body = attributes[ "body" ] - if "commit_id" in attributes: + if "commit_id" in attributes and attributes[ "commit_id" ] is not None: self.__commit_id = attributes[ "commit_id" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "line" in attributes: + if "line" in attributes and attributes[ "line" ] is not None: self.__line = attributes[ "line" ] - if "path" in attributes: + if "path" in attributes and attributes[ "path" ] is not None: self.__path = attributes[ "path" ] - if "position" in attributes: + if "position" in attributes and attributes[ "position" ] is not None: self.__position = attributes[ "position" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "user" in attributes: + if "user" in attributes and attributes[ "user" ] is not None: self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True ) diff --git a/github/GithubObjects/Download.py b/github/GithubObjects/Download.py index 00f0255f..feea6a7b 100644 --- a/github/GithubObjects/Download.py +++ b/github/GithubObjects/Download.py @@ -164,43 +164,43 @@ class Download( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "accesskeyid" in attributes: + if "accesskeyid" in attributes and attributes[ "accesskeyid" ] is not None: self.__accesskeyid = attributes[ "accesskeyid" ] - if "acl" in attributes: + if "acl" in attributes and attributes[ "acl" ] is not None: self.__acl = attributes[ "acl" ] - if "bucket" in attributes: + if "bucket" in attributes and attributes[ "bucket" ] is not None: self.__bucket = attributes[ "bucket" ] - if "content_type" in attributes: + if "content_type" in attributes and attributes[ "content_type" ] is not None: self.__content_type = attributes[ "content_type" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "description" in attributes: + if "description" in attributes and attributes[ "description" ] is not None: self.__description = attributes[ "description" ] - if "download_count" in attributes: + if "download_count" in attributes and attributes[ "download_count" ] is not None: self.__download_count = attributes[ "download_count" ] - if "expirationdate" in attributes: + if "expirationdate" in attributes and attributes[ "expirationdate" ] is not None: self.__expirationdate = attributes[ "expirationdate" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "mime_type" in attributes: + if "mime_type" in attributes and attributes[ "mime_type" ] is not None: self.__mime_type = attributes[ "mime_type" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "path" in attributes: + if "path" in attributes and attributes[ "path" ] is not None: self.__path = attributes[ "path" ] - if "policy" in attributes: + if "policy" in attributes and attributes[ "policy" ] is not None: self.__policy = attributes[ "policy" ] - if "prefix" in attributes: + if "prefix" in attributes and attributes[ "prefix" ] is not None: self.__prefix = attributes[ "prefix" ] - if "redirect" in attributes: + if "redirect" in attributes and attributes[ "redirect" ] is not None: self.__redirect = attributes[ "redirect" ] - if "s3_url" in attributes: + if "s3_url" in attributes and attributes[ "s3_url" ] is not None: self.__s3_url = attributes[ "s3_url" ] - if "signature" in attributes: + if "signature" in attributes and attributes[ "signature" ] is not None: self.__signature = attributes[ "signature" ] - if "size" in attributes: + if "size" in attributes and attributes[ "size" ] is not None: self.__size = attributes[ "size" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Event.py b/github/GithubObjects/Event.py index a5112ead..2a5d92b6 100644 --- a/github/GithubObjects/Event.py +++ b/github/GithubObjects/Event.py @@ -111,27 +111,27 @@ class Event( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "actor" in attributes: + if "actor" in attributes and attributes[ "actor" ] is not None: self.__actor = NamedUser.NamedUser( self.__requester, attributes[ "actor" ], lazy = True ) - if "commit_id" in attributes: + if "commit_id" in attributes and attributes[ "commit_id" ] is not None: self.__commit_id = attributes[ "commit_id" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "event" in attributes: + if "event" in attributes and attributes[ "event" ] is not None: self.__event = attributes[ "event" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "issue" in attributes: + if "issue" in attributes and attributes[ "issue" ] is not None: self.__issue = attributes[ "issue" ] - if "org" in attributes: + if "org" in attributes and attributes[ "org" ] is not None: self.__org = Organization.Organization( self.__requester, attributes[ "org" ], lazy = True ) - if "payload" in attributes: + if "payload" in attributes and attributes[ "payload" ] is not None: self.__payload = attributes[ "payload" ] - if "public" in attributes: + if "public" in attributes and attributes[ "public" ] is not None: self.__public = attributes[ "public" ] - if "repo" in attributes: + if "repo" in attributes and attributes[ "repo" ] is not None: self.__repo = Repository.Repository( self.__requester, attributes[ "repo" ], lazy = True ) - if "type" in attributes: + if "type" in attributes and attributes[ "type" ] is not None: self.__type = attributes[ "type" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Gist.py b/github/GithubObjects/Gist.py index 7831a069..0d3831cc 100644 --- a/github/GithubObjects/Gist.py +++ b/github/GithubObjects/Gist.py @@ -131,7 +131,7 @@ class Gist( object ): def get_comment( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/comments/" + str( id ), + str( self.url ) + "/comments" + "/" + str( id ), None, None ) @@ -193,31 +193,31 @@ class Gist( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "comments" in attributes: + if "comments" in attributes and attributes[ "comments" ] is not None: self.__comments = attributes[ "comments" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "description" in attributes: + if "description" in attributes and attributes[ "description" ] is not None: self.__description = attributes[ "description" ] - if "files" in attributes: + if "files" in attributes and attributes[ "files" ] is not None: self.__files = attributes[ "files" ] - if "forks" in attributes: + if "forks" in attributes and attributes[ "forks" ] is not None: self.__forks = attributes[ "forks" ] - if "git_pull_url" in attributes: + if "git_pull_url" in attributes and attributes[ "git_pull_url" ] is not None: self.__git_pull_url = attributes[ "git_pull_url" ] - if "git_push_url" in attributes: + if "git_push_url" in attributes and attributes[ "git_push_url" ] is not None: self.__git_push_url = attributes[ "git_push_url" ] - if "history" in attributes: + if "history" in attributes and attributes[ "history" ] is not None: self.__history = attributes[ "history" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "public" in attributes: + if "public" in attributes and attributes[ "public" ] is not None: self.__public = attributes[ "public" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "user" in attributes: + if "user" in attributes and attributes[ "user" ] is not None: self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True ) diff --git a/github/GithubObjects/GistComment.py b/github/GithubObjects/GistComment.py index 7ae90cbc..b6cd2eb1 100644 --- a/github/GithubObjects/GistComment.py +++ b/github/GithubObjects/GistComment.py @@ -93,15 +93,15 @@ class GistComment( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "body" in attributes: + if "body" in attributes and attributes[ "body" ] is not None: self.__body = attributes[ "body" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "user" in attributes: + if "user" in attributes and attributes[ "user" ] is not None: self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True ) diff --git a/github/GithubObjects/GitBlob.py b/github/GithubObjects/GitBlob.py index 43150368..eb43f098 100644 --- a/github/GithubObjects/GitBlob.py +++ b/github/GithubObjects/GitBlob.py @@ -66,13 +66,13 @@ class GitBlob( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "content" in attributes: + if "content" in attributes and attributes[ "content" ] is not None: self.__content = attributes[ "content" ] - if "encoding" in attributes: + if "encoding" in attributes and attributes[ "encoding" ] is not None: self.__encoding = attributes[ "encoding" ] - if "sha" in attributes: + if "sha" in attributes and attributes[ "sha" ] is not None: self.__sha = attributes[ "sha" ] - if "size" in attributes: + if "size" in attributes and attributes[ "size" ] is not None: self.__size = attributes[ "size" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/GitCommit.py b/github/GithubObjects/GitCommit.py index 45ef0241..0125cff5 100644 --- a/github/GithubObjects/GitCommit.py +++ b/github/GithubObjects/GitCommit.py @@ -79,17 +79,17 @@ class GitCommit( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "author" in attributes: + if "author" in attributes and attributes[ "author" ] is not None: self.__author = attributes[ "author" ] - if "committer" in attributes: + if "committer" in attributes and attributes[ "committer" ] is not None: self.__committer = attributes[ "committer" ] - if "message" in attributes: + if "message" in attributes and attributes[ "message" ] is not None: self.__message = attributes[ "message" ] - if "parents" in attributes: + if "parents" in attributes and attributes[ "parents" ] is not None: self.__parents = attributes[ "parents" ] - if "sha" in attributes: + if "sha" in attributes and attributes[ "sha" ] is not None: self.__sha = attributes[ "sha" ] - if "tree" in attributes: + if "tree" in attributes and attributes[ "tree" ] is not None: self.__tree = GitTree.GitTree( self.__requester, attributes[ "tree" ], lazy = True ) - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/GitRef.py b/github/GithubObjects/GitRef.py index e4aad4b3..8b5112c2 100644 --- a/github/GithubObjects/GitRef.py +++ b/github/GithubObjects/GitRef.py @@ -76,9 +76,9 @@ class GitRef( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "object" in attributes: + if "object" in attributes and attributes[ "object" ] is not None: self.__object = attributes[ "object" ] - if "ref" in attributes: + if "ref" in attributes and attributes[ "ref" ] is not None: self.__ref = attributes[ "ref" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/GitTag.py b/github/GithubObjects/GitTag.py index b9dd9c42..5d3092c5 100644 --- a/github/GithubObjects/GitTag.py +++ b/github/GithubObjects/GitTag.py @@ -72,15 +72,15 @@ class GitTag( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "message" in attributes: + if "message" in attributes and attributes[ "message" ] is not None: self.__message = attributes[ "message" ] - if "object" in attributes: + if "object" in attributes and attributes[ "object" ] is not None: self.__object = attributes[ "object" ] - if "sha" in attributes: + if "sha" in attributes and attributes[ "sha" ] is not None: self.__sha = attributes[ "sha" ] - if "tag" in attributes: + if "tag" in attributes and attributes[ "tag" ] is not None: self.__tag = attributes[ "tag" ] - if "tagger" in attributes: + if "tagger" in attributes and attributes[ "tagger" ] is not None: self.__tagger = attributes[ "tagger" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/GitTree.py b/github/GithubObjects/GitTree.py index 1b135bdc..06fd45c0 100644 --- a/github/GithubObjects/GitTree.py +++ b/github/GithubObjects/GitTree.py @@ -60,11 +60,11 @@ class GitTree( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "recursive" in attributes: + if "recursive" in attributes and attributes[ "recursive" ] is not None: self.__recursive = attributes[ "recursive" ] - if "sha" in attributes: + if "sha" in attributes and attributes[ "sha" ] is not None: self.__sha = attributes[ "sha" ] - if "tree" in attributes: + if "tree" in attributes and attributes[ "tree" ] is not None: self.__tree = attributes[ "tree" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Hook.py b/github/GithubObjects/Hook.py index 42f1ff83..cbc2880c 100644 --- a/github/GithubObjects/Hook.py +++ b/github/GithubObjects/Hook.py @@ -127,21 +127,21 @@ class Hook( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "active" in attributes: + if "active" in attributes and attributes[ "active" ] is not None: self.__active = attributes[ "active" ] - if "config" in attributes: + if "config" in attributes and attributes[ "config" ] is not None: self.__config = attributes[ "config" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "events" in attributes: + if "events" in attributes and attributes[ "events" ] is not None: self.__events = attributes[ "events" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "last_response" in attributes: + if "last_response" in attributes and attributes[ "last_response" ] is not None: self.__last_response = attributes[ "last_response" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Issue.py b/github/GithubObjects/Issue.py index 458e08e5..cc11930d 100644 --- a/github/GithubObjects/Issue.py +++ b/github/GithubObjects/Issue.py @@ -157,7 +157,7 @@ class Issue( object ): def get_comment( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/comments/" + str( id ), + str( self.url ) + "/comments" + "/" + str( id ), None, None ) @@ -208,7 +208,7 @@ class Issue( object ): def remove_from_labels( self, label ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/labels/" + str( label._identity ), + str( self.url ) + "/labels" + "/" + str( label._identity ), None, None ) @@ -252,37 +252,37 @@ class Issue( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "assignee" in attributes: + if "assignee" in attributes and attributes[ "assignee" ] is not None: self.__assignee = NamedUser.NamedUser( self.__requester, attributes[ "assignee" ], lazy = True ) - if "body" in attributes: + if "body" in attributes and attributes[ "body" ] is not None: self.__body = attributes[ "body" ] - if "closed_at" in attributes: + if "closed_at" in attributes and attributes[ "closed_at" ] is not None: self.__closed_at = attributes[ "closed_at" ] - if "closed_by" in attributes: + if "closed_by" in attributes and attributes[ "closed_by" ] is not None: self.__closed_by = attributes[ "closed_by" ] - if "comments" in attributes: + if "comments" in attributes and attributes[ "comments" ] is not None: self.__comments = attributes[ "comments" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "labels" in attributes: + if "labels" in attributes and attributes[ "labels" ] is not None: self.__labels = attributes[ "labels" ] - if "milestone" in attributes: + if "milestone" in attributes and attributes[ "milestone" ] is not None: self.__milestone = Milestone.Milestone( self.__requester, attributes[ "milestone" ], lazy = True ) - if "number" in attributes: + if "number" in attributes and attributes[ "number" ] is not None: self.__number = attributes[ "number" ] - if "pull_request" in attributes: + if "pull_request" in attributes and attributes[ "pull_request" ] is not None: self.__pull_request = attributes[ "pull_request" ] - if "state" in attributes: + if "state" in attributes and attributes[ "state" ] is not None: self.__state = attributes[ "state" ] - if "title" in attributes: + if "title" in attributes and attributes[ "title" ] is not None: self.__title = attributes[ "title" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "user" in attributes: + if "user" in attributes and attributes[ "user" ] is not None: self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True ) diff --git a/github/GithubObjects/IssueComment.py b/github/GithubObjects/IssueComment.py index 752a779a..8aab4abb 100644 --- a/github/GithubObjects/IssueComment.py +++ b/github/GithubObjects/IssueComment.py @@ -93,15 +93,15 @@ class IssueComment( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "body" in attributes: + if "body" in attributes and attributes[ "body" ] is not None: self.__body = attributes[ "body" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "user" in attributes: + if "user" in attributes and attributes[ "user" ] is not None: self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True ) diff --git a/github/GithubObjects/IssueEvent.py b/github/GithubObjects/IssueEvent.py index 242e6a7e..2108c095 100644 --- a/github/GithubObjects/IssueEvent.py +++ b/github/GithubObjects/IssueEvent.py @@ -79,17 +79,17 @@ class IssueEvent( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "actor" in attributes: + if "actor" in attributes and attributes[ "actor" ] is not None: self.__actor = NamedUser.NamedUser( self.__requester, attributes[ "actor" ], lazy = True ) - if "commit_id" in attributes: + if "commit_id" in attributes and attributes[ "commit_id" ] is not None: self.__commit_id = attributes[ "commit_id" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "event" in attributes: + if "event" in attributes and attributes[ "event" ] is not None: self.__event = attributes[ "event" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "issue" in attributes: + if "issue" in attributes and attributes[ "issue" ] is not None: self.__issue = attributes[ "issue" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Label.py b/github/GithubObjects/Label.py index f279de37..a836c5ea 100644 --- a/github/GithubObjects/Label.py +++ b/github/GithubObjects/Label.py @@ -75,9 +75,9 @@ class Label( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "color" in attributes: + if "color" in attributes and attributes[ "color" ] is not None: self.__color = attributes[ "color" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Milestone.py b/github/GithubObjects/Milestone.py index 2f52ba71..c5b544b7 100644 --- a/github/GithubObjects/Milestone.py +++ b/github/GithubObjects/Milestone.py @@ -138,23 +138,23 @@ class Milestone( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "closed_issues" in attributes: + if "closed_issues" in attributes and attributes[ "closed_issues" ] is not None: self.__closed_issues = attributes[ "closed_issues" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "creator" in attributes: + if "creator" in attributes and attributes[ "creator" ] is not None: self.__creator = NamedUser.NamedUser( self.__requester, attributes[ "creator" ], lazy = True ) - if "description" in attributes: + if "description" in attributes and attributes[ "description" ] is not None: self.__description = attributes[ "description" ] - if "due_on" in attributes: + if "due_on" in attributes and attributes[ "due_on" ] is not None: self.__due_on = attributes[ "due_on" ] - if "number" in attributes: + if "number" in attributes and attributes[ "number" ] is not None: self.__number = attributes[ "number" ] - if "open_issues" in attributes: + if "open_issues" in attributes and attributes[ "open_issues" ] is not None: self.__open_issues = attributes[ "open_issues" ] - if "state" in attributes: + if "state" in attributes and attributes[ "state" ] is not None: self.__state = attributes[ "state" ] - if "title" in attributes: + if "title" in attributes and attributes[ "title" ] is not None: self.__title = attributes[ "title" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/NamedUser.py b/github/GithubObjects/NamedUser.py index b77cbd34..b22886fd 100644 --- a/github/GithubObjects/NamedUser.py +++ b/github/GithubObjects/NamedUser.py @@ -366,55 +366,55 @@ class NamedUser( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "avatar_url" in attributes: + if "avatar_url" in attributes and attributes[ "avatar_url" ] is not None: self.__avatar_url = attributes[ "avatar_url" ] - if "bio" in attributes: + if "bio" in attributes and attributes[ "bio" ] is not None: self.__bio = attributes[ "bio" ] - if "blog" in attributes: + if "blog" in attributes and attributes[ "blog" ] is not None: self.__blog = attributes[ "blog" ] - if "collaborators" in attributes: + if "collaborators" in attributes and attributes[ "collaborators" ] is not None: self.__collaborators = attributes[ "collaborators" ] - if "company" in attributes: + if "company" in attributes and attributes[ "company" ] is not None: self.__company = attributes[ "company" ] - if "contributions" in attributes: + if "contributions" in attributes and attributes[ "contributions" ] is not None: self.__contributions = attributes[ "contributions" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "disk_usage" in attributes: + if "disk_usage" in attributes and attributes[ "disk_usage" ] is not None: self.__disk_usage = attributes[ "disk_usage" ] - if "email" in attributes: + if "email" in attributes and attributes[ "email" ] is not None: self.__email = attributes[ "email" ] - if "followers" in attributes: + if "followers" in attributes and attributes[ "followers" ] is not None: self.__followers = attributes[ "followers" ] - if "following" in attributes: + if "following" in attributes and attributes[ "following" ] is not None: self.__following = attributes[ "following" ] - if "gravatar_id" in attributes: + if "gravatar_id" in attributes and attributes[ "gravatar_id" ] is not None: self.__gravatar_id = attributes[ "gravatar_id" ] - if "hireable" in attributes: + if "hireable" in attributes and attributes[ "hireable" ] is not None: self.__hireable = attributes[ "hireable" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "location" in attributes: + if "location" in attributes and attributes[ "location" ] is not None: self.__location = attributes[ "location" ] - if "login" in attributes: + if "login" in attributes and attributes[ "login" ] is not None: self.__login = attributes[ "login" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "owned_private_repos" in attributes: + if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None: self.__owned_private_repos = attributes[ "owned_private_repos" ] - if "plan" in attributes: + if "plan" in attributes and attributes[ "plan" ] is not None: self.__plan = attributes[ "plan" ] - if "private_gists" in attributes: + if "private_gists" in attributes and attributes[ "private_gists" ] is not None: self.__private_gists = attributes[ "private_gists" ] - if "public_gists" in attributes: + if "public_gists" in attributes and attributes[ "public_gists" ] is not None: self.__public_gists = attributes[ "public_gists" ] - if "public_repos" in attributes: + if "public_repos" in attributes and attributes[ "public_repos" ] is not None: self.__public_repos = attributes[ "public_repos" ] - if "total_private_repos" in attributes: + if "total_private_repos" in attributes and attributes[ "total_private_repos" ] is not None: self.__total_private_repos = attributes[ "total_private_repos" ] - if "type" in attributes: + if "type" in attributes and attributes[ "type" ] is not None: self.__type = attributes[ "type" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Organization.py b/github/GithubObjects/Organization.py index 01f92a2b..7c5e5a0e 100644 --- a/github/GithubObjects/Organization.py +++ b/github/GithubObjects/Organization.py @@ -144,7 +144,7 @@ class Organization( object ): def add_to_public_members( self, public_member ): status, headers, data = self.__requester.request( "PUT", - str( self.url ) + "/public_members/" + str( public_member._identity ), + str( self.url ) + "/public_members" + "/" + str( public_member._identity ), None, None ) @@ -308,7 +308,7 @@ class Organization( object ): def has_in_members( self, member ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/members/" + str( member._identity ), + str( self.url ) + "/members" + "/" + str( member._identity ), None, None ) @@ -317,7 +317,7 @@ class Organization( object ): def has_in_public_members( self, public_member ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/public_members/" + str( public_member._identity ), + str( self.url ) + "/public_members" + "/" + str( public_member._identity ), None, None ) @@ -326,7 +326,7 @@ class Organization( object ): def remove_from_members( self, member ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/members/" + str( member._identity ), + str( self.url ) + "/members" + "/" + str( member._identity ), None, None ) @@ -334,7 +334,7 @@ class Organization( object ): def remove_from_public_members( self, public_member ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/public_members/" + str( public_member._identity ), + str( self.url ) + "/public_members" + "/" + str( public_member._identity ), None, None ) @@ -382,51 +382,51 @@ class Organization( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "avatar_url" in attributes: + if "avatar_url" in attributes and attributes[ "avatar_url" ] is not None: self.__avatar_url = attributes[ "avatar_url" ] - if "billing_email" in attributes: + if "billing_email" in attributes and attributes[ "billing_email" ] is not None: self.__billing_email = attributes[ "billing_email" ] - if "blog" in attributes: + if "blog" in attributes and attributes[ "blog" ] is not None: self.__blog = attributes[ "blog" ] - if "collaborators" in attributes: + if "collaborators" in attributes and attributes[ "collaborators" ] is not None: self.__collaborators = attributes[ "collaborators" ] - if "company" in attributes: + if "company" in attributes and attributes[ "company" ] is not None: self.__company = attributes[ "company" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "disk_usage" in attributes: + if "disk_usage" in attributes and attributes[ "disk_usage" ] is not None: self.__disk_usage = attributes[ "disk_usage" ] - if "email" in attributes: + if "email" in attributes and attributes[ "email" ] is not None: self.__email = attributes[ "email" ] - if "followers" in attributes: + if "followers" in attributes and attributes[ "followers" ] is not None: self.__followers = attributes[ "followers" ] - if "following" in attributes: + if "following" in attributes and attributes[ "following" ] is not None: self.__following = attributes[ "following" ] - if "gravatar_id" in attributes: + if "gravatar_id" in attributes and attributes[ "gravatar_id" ] is not None: self.__gravatar_id = attributes[ "gravatar_id" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "location" in attributes: + if "location" in attributes and attributes[ "location" ] is not None: self.__location = attributes[ "location" ] - if "login" in attributes: + if "login" in attributes and attributes[ "login" ] is not None: self.__login = attributes[ "login" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "owned_private_repos" in attributes: + if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None: self.__owned_private_repos = attributes[ "owned_private_repos" ] - if "plan" in attributes: + if "plan" in attributes and attributes[ "plan" ] is not None: self.__plan = attributes[ "plan" ] - if "private_gists" in attributes: + if "private_gists" in attributes and attributes[ "private_gists" ] is not None: self.__private_gists = attributes[ "private_gists" ] - if "public_gists" in attributes: + if "public_gists" in attributes and attributes[ "public_gists" ] is not None: self.__public_gists = attributes[ "public_gists" ] - if "public_repos" in attributes: + if "public_repos" in attributes and attributes[ "public_repos" ] is not None: self.__public_repos = attributes[ "public_repos" ] - if "total_private_repos" in attributes: + if "total_private_repos" in attributes and attributes[ "total_private_repos" ] is not None: self.__total_private_repos = attributes[ "total_private_repos" ] - if "type" in attributes: + if "type" in attributes and attributes[ "type" ] is not None: self.__type = attributes[ "type" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/PullRequest.py b/github/GithubObjects/PullRequest.py index a9fb9fc1..99e93688 100644 --- a/github/GithubObjects/PullRequest.py +++ b/github/GithubObjects/PullRequest.py @@ -171,7 +171,7 @@ class PullRequest( object ): def get_comment( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/comments/" + str( id ), + str( self.url ) + "/comments" + "/" + str( id ), None, None ) @@ -281,55 +281,55 @@ class PullRequest( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "additions" in attributes: + if "additions" in attributes and attributes[ "additions" ] is not None: self.__additions = attributes[ "additions" ] - if "base" in attributes: + if "base" in attributes and attributes[ "base" ] is not None: self.__base = attributes[ "base" ] - if "body" in attributes: + if "body" in attributes and attributes[ "body" ] is not None: self.__body = attributes[ "body" ] - if "changed_files" in attributes: + if "changed_files" in attributes and attributes[ "changed_files" ] is not None: self.__changed_files = attributes[ "changed_files" ] - if "closed_at" in attributes: + if "closed_at" in attributes and attributes[ "closed_at" ] is not None: self.__closed_at = attributes[ "closed_at" ] - if "comments" in attributes: + if "comments" in attributes and attributes[ "comments" ] is not None: self.__comments = attributes[ "comments" ] - if "commits" in attributes: + if "commits" in attributes and attributes[ "commits" ] is not None: self.__commits = attributes[ "commits" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "deletions" in attributes: + if "deletions" in attributes and attributes[ "deletions" ] is not None: self.__deletions = attributes[ "deletions" ] - if "diff_url" in attributes: + if "diff_url" in attributes and attributes[ "diff_url" ] is not None: self.__diff_url = attributes[ "diff_url" ] - if "head" in attributes: + if "head" in attributes and attributes[ "head" ] is not None: self.__head = attributes[ "head" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "issue_url" in attributes: + if "issue_url" in attributes and attributes[ "issue_url" ] is not None: self.__issue_url = attributes[ "issue_url" ] - if "mergeable" in attributes: + if "mergeable" in attributes and attributes[ "mergeable" ] is not None: self.__mergeable = attributes[ "mergeable" ] - if "merged" in attributes: + if "merged" in attributes and attributes[ "merged" ] is not None: self.__merged = attributes[ "merged" ] - if "merged_at" in attributes: + if "merged_at" in attributes and attributes[ "merged_at" ] is not None: self.__merged_at = attributes[ "merged_at" ] - if "merged_by" in attributes: + if "merged_by" in attributes and attributes[ "merged_by" ] is not None: self.__merged_by = attributes[ "merged_by" ] - if "number" in attributes: + if "number" in attributes and attributes[ "number" ] is not None: self.__number = attributes[ "number" ] - if "patch_url" in attributes: + if "patch_url" in attributes and attributes[ "patch_url" ] is not None: self.__patch_url = attributes[ "patch_url" ] - if "review_comments" in attributes: + if "review_comments" in attributes and attributes[ "review_comments" ] is not None: self.__review_comments = attributes[ "review_comments" ] - if "state" in attributes: + if "state" in attributes and attributes[ "state" ] is not None: self.__state = attributes[ "state" ] - if "title" in attributes: + if "title" in attributes and attributes[ "title" ] is not None: self.__title = attributes[ "title" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "user" in attributes: + if "user" in attributes and attributes[ "user" ] is not None: self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True ) diff --git a/github/GithubObjects/PullRequestComment.py b/github/GithubObjects/PullRequestComment.py index a186de7b..b71d5a6e 100644 --- a/github/GithubObjects/PullRequestComment.py +++ b/github/GithubObjects/PullRequestComment.py @@ -123,25 +123,25 @@ class PullRequestComment( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "body" in attributes: + if "body" in attributes and attributes[ "body" ] is not None: self.__body = attributes[ "body" ] - if "commit_id" in attributes: + if "commit_id" in attributes and attributes[ "commit_id" ] is not None: self.__commit_id = attributes[ "commit_id" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "line" in attributes: + if "line" in attributes and attributes[ "line" ] is not None: self.__line = attributes[ "line" ] - if "path" in attributes: + if "path" in attributes and attributes[ "path" ] is not None: self.__path = attributes[ "path" ] - if "position" in attributes: + if "position" in attributes and attributes[ "position" ] is not None: self.__position = attributes[ "position" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "user" in attributes: + if "user" in attributes and attributes[ "user" ] is not None: self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True ) diff --git a/github/GithubObjects/PullRequestFile.py b/github/GithubObjects/PullRequestFile.py index 6da4f590..e6cee7e7 100644 --- a/github/GithubObjects/PullRequestFile.py +++ b/github/GithubObjects/PullRequestFile.py @@ -90,21 +90,21 @@ class PullRequestFile( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "additions" in attributes: + if "additions" in attributes and attributes[ "additions" ] is not None: self.__additions = attributes[ "additions" ] - if "blob_url" in attributes: + if "blob_url" in attributes and attributes[ "blob_url" ] is not None: self.__blob_url = attributes[ "blob_url" ] - if "changes" in attributes: + if "changes" in attributes and attributes[ "changes" ] is not None: self.__changes = attributes[ "changes" ] - if "deletions" in attributes: + if "deletions" in attributes and attributes[ "deletions" ] is not None: self.__deletions = attributes[ "deletions" ] - if "filename" in attributes: + if "filename" in attributes and attributes[ "filename" ] is not None: self.__filename = attributes[ "filename" ] - if "patch" in attributes: + if "patch" in attributes and attributes[ "patch" ] is not None: self.__patch = attributes[ "patch" ] - if "raw_url" in attributes: + if "raw_url" in attributes and attributes[ "raw_url" ] is not None: self.__raw_url = attributes[ "raw_url" ] - if "sha" in attributes: + if "sha" in attributes and attributes[ "sha" ] is not None: self.__sha = attributes[ "sha" ] - if "status" in attributes: + if "status" in attributes and attributes[ "status" ] is not None: self.__status = attributes[ "status" ] diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 6ca54ba1..09128c80 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -191,7 +191,7 @@ class Repository( object ): def add_to_collaborators( self, collaborator ): status, headers, data = self.__requester.request( "PUT", - str( self.url ) + "/collaborators/" + str( collaborator._identity ), + str( self.url ) + "/collaborators" + "/" + str( collaborator._identity ), None, None ) @@ -427,7 +427,7 @@ class Repository( object ): def get_comment( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/comments/" + str( id ), + str( self.url ) + "/comments" + "/" + str( id ), None, None ) @@ -450,7 +450,7 @@ class Repository( object ): def get_commit( self, sha ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/commits/" + str( sha ), + str( self.url ) + "/commits" + "/" + str( sha ), None, None ) @@ -487,7 +487,7 @@ class Repository( object ): def get_download( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/downloads/" + str( id ), + str( self.url ) + "/downloads" + "/" + str( id ), None, None ) @@ -538,7 +538,7 @@ class Repository( object ): def get_git_blob( self, sha ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/git_blobs/" + str( sha ), + str( self.url ) + "/git_blobs" + "/" + str( sha ), None, None ) @@ -547,7 +547,7 @@ class Repository( object ): def get_git_commit( self, sha ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/git_commits/" + str( sha ), + str( self.url ) + "/git_commits" + "/" + str( sha ), None, None ) @@ -556,7 +556,7 @@ class Repository( object ): def get_git_ref( self, ref ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/git_refs/" + str( ref ), + str( self.url ) + "/git_refs" + "/" + str( ref ), None, None ) @@ -579,7 +579,7 @@ class Repository( object ): def get_git_tag( self, sha ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/git_tags/" + str( sha ), + str( self.url ) + "/git_tags" + "/" + str( sha ), None, None ) @@ -588,7 +588,7 @@ class Repository( object ): def get_git_tree( self, sha, recursive = DefaultValueForOptionalParameters ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/git_trees/" + str( sha ), + str( self.url ) + "/git_trees" + "/" + str( sha ), None, None ) @@ -597,7 +597,7 @@ class Repository( object ): def get_hook( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/hooks/" + str( id ), + str( self.url ) + "/hooks" + "/" + str( id ), None, None ) @@ -620,7 +620,7 @@ class Repository( object ): def get_issue( self, number ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/issues/" + str( number ), + str( self.url ) + "/issues" + "/" + str( number ), None, None ) @@ -643,7 +643,7 @@ class Repository( object ): def get_issues_event( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/issues_events/" + str( id ), + str( self.url ) + "/issues/events" + "/" + str( id ), None, None ) @@ -652,7 +652,7 @@ class Repository( object ): def get_issues_events( self ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/issues_events", + str( self.url ) + "/issues/events", None, None ) @@ -666,7 +666,7 @@ class Repository( object ): def get_key( self, id ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/keys/" + str( id ), + str( self.url ) + "/keys" + "/" + str( id ), None, None ) @@ -689,7 +689,7 @@ class Repository( object ): def get_label( self, name ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/labels/" + str( name ), + str( self.url ) + "/labels" + "/" + str( name ), None, None ) @@ -715,7 +715,7 @@ class Repository( object ): def get_milestone( self, number ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/milestones/" + str( number ), + str( self.url ) + "/milestones" + "/" + str( number ), None, None ) @@ -736,12 +736,23 @@ class Repository( object ): ) def get_network_events( self ): - pass + status, headers, data = self.__requester.request( + "GET", + "https://api.github.com/networks/" + str( self.owner.login ) + "/" + str( self.name ) + "/events", + None, + None + ) + return PaginatedList.PaginatedList( + Event.Event, + self.__requester, + headers, + data + ) def get_pull( self, number ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/pulls/" + str( number ), + str( self.url ) + "/pulls" + "/" + str( number ), None, None ) @@ -806,7 +817,7 @@ class Repository( object ): def has_in_collaborators( self, collaborator ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/collaborators/" + str( collaborator._identity ), + str( self.url ) + "/collaborators" + "/" + str( collaborator._identity ), None, None ) @@ -815,7 +826,7 @@ class Repository( object ): def remove_from_collaborators( self, collaborator ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/collaborators/" + str( collaborator._identity ), + str( self.url ) + "/collaborators" + "/" + str( collaborator._identity ), None, None ) @@ -874,63 +885,63 @@ class Repository( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "clone_url" in attributes: + if "clone_url" in attributes and attributes[ "clone_url" ] is not None: self.__clone_url = attributes[ "clone_url" ] - if "created_at" in attributes: + if "created_at" in attributes and attributes[ "created_at" ] is not None: self.__created_at = attributes[ "created_at" ] - if "description" in attributes: + if "description" in attributes and attributes[ "description" ] is not None: self.__description = attributes[ "description" ] - if "fork" in attributes: + if "fork" in attributes and attributes[ "fork" ] is not None: self.__fork = attributes[ "fork" ] - if "forks" in attributes: + if "forks" in attributes and attributes[ "forks" ] is not None: self.__forks = attributes[ "forks" ] - if "git_url" in attributes: + if "git_url" in attributes and attributes[ "git_url" ] is not None: self.__git_url = attributes[ "git_url" ] - if "has_downloads" in attributes: + if "has_downloads" in attributes and attributes[ "has_downloads" ] is not None: self.__has_downloads = attributes[ "has_downloads" ] - if "has_issues" in attributes: + if "has_issues" in attributes and attributes[ "has_issues" ] is not None: self.__has_issues = attributes[ "has_issues" ] - if "has_wiki" in attributes: + if "has_wiki" in attributes and attributes[ "has_wiki" ] is not None: self.__has_wiki = attributes[ "has_wiki" ] - if "homepage" in attributes: + if "homepage" in attributes and attributes[ "homepage" ] is not None: self.__homepage = attributes[ "homepage" ] - if "html_url" in attributes: + if "html_url" in attributes and attributes[ "html_url" ] is not None: self.__html_url = attributes[ "html_url" ] - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "language" in attributes: + if "language" in attributes and attributes[ "language" ] is not None: self.__language = attributes[ "language" ] - if "master_branch" in attributes: + if "master_branch" in attributes and attributes[ "master_branch" ] is not None: self.__master_branch = attributes[ "master_branch" ] - if "mirror_url" in attributes: + if "mirror_url" in attributes and attributes[ "mirror_url" ] is not None: self.__mirror_url = attributes[ "mirror_url" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "open_issues" in attributes: + if "open_issues" in attributes and attributes[ "open_issues" ] is not None: self.__open_issues = attributes[ "open_issues" ] - if "organization" in attributes: + if "organization" in attributes and attributes[ "organization" ] is not None: self.__organization = attributes[ "organization" ] - if "owner" in attributes: + if "owner" in attributes and attributes[ "owner" ] is not None: self.__owner = NamedUser.NamedUser( self.__requester, attributes[ "owner" ], lazy = True ) - if "parent" in attributes: + if "parent" in attributes and attributes[ "parent" ] is not None: self.__parent = Repository( self.__requester, attributes[ "parent" ], lazy = True ) - if "permissions" in attributes: + if "permissions" in attributes and attributes[ "permissions" ] is not None: self.__permissions = attributes[ "permissions" ] - if "private" in attributes: + if "private" in attributes and attributes[ "private" ] is not None: self.__private = attributes[ "private" ] - if "pushed_at" in attributes: + if "pushed_at" in attributes and attributes[ "pushed_at" ] is not None: self.__pushed_at = attributes[ "pushed_at" ] - if "size" in attributes: + if "size" in attributes and attributes[ "size" ] is not None: self.__size = attributes[ "size" ] - if "source" in attributes: + if "source" in attributes and attributes[ "source" ] is not None: self.__source = Repository( self.__requester, attributes[ "source" ], lazy = True ) - if "ssh_url" in attributes: + if "ssh_url" in attributes and attributes[ "ssh_url" ] is not None: self.__ssh_url = attributes[ "ssh_url" ] - if "svn_url" in attributes: + if "svn_url" in attributes and attributes[ "svn_url" ] is not None: self.__svn_url = attributes[ "svn_url" ] - if "updated_at" in attributes: + if "updated_at" in attributes and attributes[ "updated_at" ] is not None: self.__updated_at = attributes[ "updated_at" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] - if "watchers" in attributes: + if "watchers" in attributes and attributes[ "watchers" ] is not None: self.__watchers = attributes[ "watchers" ] diff --git a/github/GithubObjects/RepositoryKey.py b/github/GithubObjects/RepositoryKey.py index 4b896a45..3f1b2532 100644 --- a/github/GithubObjects/RepositoryKey.py +++ b/github/GithubObjects/RepositoryKey.py @@ -81,11 +81,11 @@ class RepositoryKey( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "key" in attributes: + if "key" in attributes and attributes[ "key" ] is not None: self.__key = attributes[ "key" ] - if "title" in attributes: + if "title" in attributes and attributes[ "title" ] is not None: self.__title = attributes[ "title" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/Tag.py b/github/GithubObjects/Tag.py index d43ca085..f0333600 100644 --- a/github/GithubObjects/Tag.py +++ b/github/GithubObjects/Tag.py @@ -61,11 +61,11 @@ class Tag( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "commit" in attributes: + if "commit" in attributes and attributes[ "commit" ] is not None: self.__commit = Commit.Commit( self.__requester, attributes[ "commit" ], lazy = True ) - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "tarball_url" in attributes: + if "tarball_url" in attributes and attributes[ "tarball_url" ] is not None: self.__tarball_url = attributes[ "tarball_url" ] - if "zipball_url" in attributes: + if "zipball_url" in attributes and attributes[ "zipball_url" ] is not None: self.__zipball_url = attributes[ "zipball_url" ] diff --git a/github/GithubObjects/Team.py b/github/GithubObjects/Team.py index 79caa67d..d5d2b010 100644 --- a/github/GithubObjects/Team.py +++ b/github/GithubObjects/Team.py @@ -52,7 +52,7 @@ class Team( object ): def add_to_members( self, member ): status, headers, data = self.__requester.request( "PUT", - str( self.url ) + "/members/" + str( member._identity ), + str( self.url ) + "/members" + "/" + str( member._identity ), None, None ) @@ -60,7 +60,7 @@ class Team( object ): def add_to_repos( self, repo ): status, headers, data = self.__requester.request( "PUT", - str( self.url ) + "/repos/" + str( repo._identity ), + str( self.url ) + "/repos" + "/" + str( repo._identity ), None, None ) @@ -118,7 +118,7 @@ class Team( object ): def has_in_members( self, member ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/members/" + str( member._identity ), + str( self.url ) + "/members" + "/" + str( member._identity ), None, None ) @@ -127,7 +127,7 @@ class Team( object ): def has_in_repos( self, repo ): status, headers, data = self.__requester.request( "GET", - str( self.url ) + "/repos/" + str( repo._identity ), + str( self.url ) + "/repos" + "/" + str( repo._identity ), None, None ) @@ -136,7 +136,7 @@ class Team( object ): def remove_from_members( self, member ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/members/" + str( member._identity ), + str( self.url ) + "/members" + "/" + str( member._identity ), None, None ) @@ -144,7 +144,7 @@ class Team( object ): def remove_from_repos( self, repo ): status, headers, data = self.__requester.request( "DELETE", - str( self.url ) + "/repos/" + str( repo._identity ), + str( self.url ) + "/repos" + "/" + str( repo._identity ), None, None ) @@ -174,15 +174,15 @@ class Team( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "members_count" in attributes: + if "members_count" in attributes and attributes[ "members_count" ] is not None: self.__members_count = attributes[ "members_count" ] - if "name" in attributes: + if "name" in attributes and attributes[ "name" ] is not None: self.__name = attributes[ "name" ] - if "permission" in attributes: + if "permission" in attributes and attributes[ "permission" ] is not None: self.__permission = attributes[ "permission" ] - if "repos_count" in attributes: + if "repos_count" in attributes and attributes[ "repos_count" ] is not None: self.__repos_count = attributes[ "repos_count" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ] diff --git a/github/GithubObjects/UserKey.py b/github/GithubObjects/UserKey.py index 2c8abc08..380d0082 100644 --- a/github/GithubObjects/UserKey.py +++ b/github/GithubObjects/UserKey.py @@ -83,11 +83,11 @@ class UserKey( object ): def __useAttributes( self, attributes ): #@todo No need to check if attribute is in attributes when attribute is mandatory - if "id" in attributes: + if "id" in attributes and attributes[ "id" ] is not None: self.__id = attributes[ "id" ] - if "key" in attributes: + if "key" in attributes and attributes[ "key" ] is not None: self.__key = attributes[ "key" ] - if "title" in attributes: + if "title" in attributes and attributes[ "title" ] is not None: self.__title = attributes[ "title" ] - if "url" in attributes: + if "url" in attributes and attributes[ "url" ] is not None: self.__url = attributes[ "url" ]