From 2defd7b81889060812afd14f1c878cb33ee5c712 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 14 Mar 2013 12:29:54 +0100 Subject: [PATCH 1/5] Expose raw data of objects (Issue #144) --- github/GithubObject.py | 23 +++++- github/tests/AllTests.py | 1 + github/tests/RawData.py | 82 +++++++++++++++++++ .../RawData.testCompletedObject.txt | 5 ++ .../RawData.testNonCompletableObject.txt | 5 ++ .../RawData.testNotYetCompletedObject.txt | 15 ++++ 6 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 github/tests/RawData.py create mode 100644 github/tests/ReplayData/RawData.testCompletedObject.txt create mode 100644 github/tests/ReplayData/RawData.testNonCompletableObject.txt create mode 100644 github/tests/ReplayData/RawData.testNotYetCompletedObject.txt diff --git a/github/GithubObject.py b/github/GithubObject.py index 26b4c283..554c2228 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -28,7 +28,22 @@ class BasicGithubObject(object): def __init__(self, requester, attributes, completed): self._requester = requester self._initAttributes() + self._storeAndUseAttributes(attributes) + + def _storeAndUseAttributes(self, attributes): self._useAttributes(attributes) + self._rawData = attributes + + @property + def raw_data(self): + """ + :type: dict + """ + self._completeIfNeeded() + return self._rawData + + def _completeIfNeeded(self): + pass @staticmethod def _parentUrl(url): @@ -59,7 +74,11 @@ class GithubObject(BasicGithubObject): self.__completed = completed def _completeIfNotSet(self, value): - if not self.__completed and value is NotSet: + if value is NotSet: + self._completeIfNeeded() + + def _completeIfNeeded(self): + if not self.__completed: self.__complete() def __complete(self): @@ -69,5 +88,5 @@ class GithubObject(BasicGithubObject): None, None ) - self._useAttributes(data) + self._storeAndUseAttributes(data) self.__completed = True diff --git a/github/tests/AllTests.py b/github/tests/AllTests.py index c72489f8..09883d3b 100644 --- a/github/tests/AllTests.py +++ b/github/tests/AllTests.py @@ -54,6 +54,7 @@ from PaginatedList import * from Exceptions import * from Enterprise import * from Logging_ import * +from RawData import * from Issue33 import * from Issue50 import * diff --git a/github/tests/RawData.py b/github/tests/RawData.py new file mode 100644 index 00000000..dd950086 --- /dev/null +++ b/github/tests/RawData.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- + +# Copyright 2012 Vincent Jacques +# vincent@vincent-jacques.net + +# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ + +# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see . + +import Framework + +class RawData(Framework.TestCase): + jacquev6RawData = { + u'disk_usage': 13812, + u'private_gists': 5, + u'public_repos': 21, + u'subscriptions_url': u'https://api.github.com/users/jacquev6/subscriptions', + u'gravatar_id': u'b68de5ae38616c296fa345d2b9df2225', + u'hireable': False, + u'id': 327146, + u'followers_url': u'https://api.github.com/users/jacquev6/followers', + u'following_url': u'https://api.github.com/users/jacquev6/following', + u'collaborators': 1, + u'total_private_repos': 4, + u'blog': u'http://vincent-jacques.net', + u'followers': 22, + u'location': u'Paris, France', + u'type': u'User', + u'email': u'vincent@vincent-jacques.net', + u'bio': u'', + u'gists_url': u'https://api.github.com/users/jacquev6/gists{/gist_id}', + u'owned_private_repos': 4, + u'company': u'Criteo', + u'events_url': u'https://api.github.com/users/jacquev6/events{/privacy}', + u'html_url': u'https://github.com/jacquev6', + u'updated_at': u'2013-03-12T22:13:32Z', + u'plan': { + u'collaborators': 1, + u'name': u'micro', + u'private_repos': 5, + u'space': 614400, + }, + u'received_events_url': u'https://api.github.com/users/jacquev6/received_events', + u'starred_url': u'https://api.github.com/users/jacquev6/starred{/owner}{/repo}', + u'public_gists': 2, + u'name': u'Vincent Jacques', + u'organizations_url': u'https://api.github.com/users/jacquev6/orgs', + u'url': u'https://api.github.com/users/jacquev6', + u'created_at': u'2010-07-09T06:10:06Z', + u'avatar_url': u'https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png', + u'repos_url': u'https://api.github.com/users/jacquev6/repos', + u'following': 38, + u'login': u'jacquev6', + } + + planRawData = { + u'collaborators': 1, + u'name': u'micro', + u'private_repos': 5, + u'space': 614400, + } + + def testCompletedObject(self): + user = self.g.get_user("jacquev6") + self.assertTrue(user._GithubObject__completed) + self.assertEqual(user.raw_data, RawData.jacquev6RawData) + + def testNotYetCompletedObject(self): + user = self.g.get_user().get_repo("PyGithub").owner + self.assertFalse(user._GithubObject__completed) + self.assertEqual(user.raw_data, RawData.jacquev6RawData) + self.assertTrue(user._GithubObject__completed) + + def testNonCompletableObject(self): + plan = self.g.get_user().plan + self.assertEqual(plan.raw_data, RawData.planRawData) diff --git a/github/tests/ReplayData/RawData.testCompletedObject.txt b/github/tests/ReplayData/RawData.testCompletedObject.txt new file mode 100644 index 00000000..0b7a93a0 --- /dev/null +++ b/github/tests/ReplayData/RawData.testCompletedObject.txt @@ -0,0 +1,5 @@ +https GET api.github.com None /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:30 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5} + diff --git a/github/tests/ReplayData/RawData.testNonCompletableObject.txt b/github/tests/ReplayData/RawData.testNonCompletableObject.txt new file mode 100644 index 00000000..ecd11acd --- /dev/null +++ b/github/tests/ReplayData/RawData.testNonCompletableObject.txt @@ -0,0 +1,5 @@ +https GET api.github.com None /user {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:31 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5} + diff --git a/github/tests/ReplayData/RawData.testNotYetCompletedObject.txt b/github/tests/ReplayData/RawData.testNotYetCompletedObject.txt new file mode 100644 index 00000000..000de223 --- /dev/null +++ b/github/tests/ReplayData/RawData.testNotYetCompletedObject.txt @@ -0,0 +1,15 @@ +https GET api.github.com None /user {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:31 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5} + +https GET api.github.com None /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '4656'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:31 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"id":3544490,"name":"PyGithub","full_name":"jacquev6/PyGithub","owner":{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User"},"private":false,"html_url":"https://github.com/jacquev6/PyGithub","description":"Python library implementing the full Github API v3","fork":false,"url":"https://api.github.com/repos/jacquev6/PyGithub","forks_url":"https://api.github.com/repos/jacquev6/PyGithub/forks","keys_url":"https://api.github.com/repos/jacquev6/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/PyGithub/teams","hooks_url":"https://api.github.com/repos/jacquev6/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/PyGithub/events","assignees_url":"https://api.github.com/repos/jacquev6/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/PyGithub/tags{/tag}","blobs_url":"https://api.github.com/repos/jacquev6/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/PyGithub/languages","stargazers_url":"https://api.github.com/repos/jacquev6/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/PyGithub/subscription","commits_url":"https://api.github.com/repos/jacquev6/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/PyGithub/issues/comments/{number}","contents_url":"https://api.github.com/repos/jacquev6/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/PyGithub/merges","archive_url":"https://api.github.com/repos/jacquev6/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/PyGithub/downloads","issues_url":"https://api.github.com/repos/jacquev6/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/PyGithub/labels{/name}","created_at":"2012-02-25T12:53:47Z","updated_at":"2013-03-12T22:13:32Z","pushed_at":"2013-03-12T09:25:23Z","git_url":"git://github.com/jacquev6/PyGithub.git","ssh_url":"git@github.com:jacquev6/PyGithub.git","clone_url":"https://github.com/jacquev6/PyGithub.git","svn_url":"https://github.com/jacquev6/PyGithub","homepage":"http://jacquev6.github.com/PyGithub","size":416,"watchers_count":167,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":47,"mirror_url":null,"open_issues_count":13,"forks":47,"open_issues":13,"watchers":167,"master_branch":"master","default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"network_count":47} + +https GET api.github.com None /users/jacquev6 {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4984'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1464'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 12 Mar 2013 22:13:32 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1bb2632b6c4ebeb4ff568329490bfbe2"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Wed, 13 Mar 2013 13:13:32 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"login":"jacquev6","id":327146,"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","name":"Vincent Jacques","company":"Criteo","blog":"http://vincent-jacques.net","location":"Paris, France","email":"vincent@vincent-jacques.net","hireable":false,"bio":"","public_repos":21,"followers":22,"following":38,"created_at":"2010-07-09T06:10:06Z","updated_at":"2013-03-12T22:13:32Z","public_gists":2,"total_private_repos":4,"owned_private_repos":4,"disk_usage":13812,"collaborators":1,"plan":{"name":"micro","space":614400,"collaborators":1,"private_repos":5},"private_gists":5} + From fa43e952688e8ad2d8808a849588e5460b029880 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 14 Mar 2013 12:31:36 +0100 Subject: [PATCH 2/5] Refactor XxxGithubObject --- github/AuthenticatedUser.py | 2 +- github/Authorization.py | 2 +- github/AuthorizationApplication.py | 2 +- github/Branch.py | 2 +- github/Commit.py | 2 +- github/CommitComment.py | 2 +- github/CommitStats.py | 2 +- github/CommitStatus.py | 2 +- github/Comparison.py | 2 +- github/ContentFile.py | 2 +- github/Download.py | 2 +- github/Event.py | 2 +- github/File.py | 2 +- github/Gist.py | 2 +- github/GistComment.py | 2 +- github/GistFile.py | 2 +- github/GistHistoryState.py | 2 +- github/GitAuthor.py | 2 +- github/GitBlob.py | 2 +- github/GitCommit.py | 2 +- github/GitObject.py | 2 +- github/GitRef.py | 2 +- github/GitTag.py | 2 +- github/GitTree.py | 2 +- github/GitTreeElement.py | 2 +- github/GithubObject.py | 14 ++++++++------ github/GitignoreTemplate.py | 2 +- github/Hook.py | 2 +- github/HookDescription.py | 2 +- github/HookResponse.py | 2 +- github/Issue.py | 2 +- github/IssueComment.py | 2 +- github/IssueEvent.py | 2 +- github/IssuePullRequest.py | 2 +- github/Label.py | 2 +- github/Milestone.py | 2 +- github/NamedUser.py | 2 +- github/Organization.py | 2 +- github/Permissions.py | 2 +- github/Plan.py | 2 +- github/PullRequest.py | 2 +- github/PullRequestComment.py | 2 +- github/PullRequestMergeStatus.py | 2 +- github/PullRequestPart.py | 2 +- github/Repository.py | 2 +- github/RepositoryKey.py | 4 ++-- github/Tag.py | 2 +- github/Team.py | 2 +- github/UserKey.py | 2 +- github/tests/Issue139.py | 4 ++-- github/tests/RawData.py | 6 +++--- 51 files changed, 62 insertions(+), 60 deletions(-) diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py index 6665c669..9e01a059 100644 --- a/github/AuthenticatedUser.py +++ b/github/AuthenticatedUser.py @@ -27,7 +27,7 @@ import github.Event import github.Authorization -class AuthenticatedUser(github.GithubObject.GithubObject): +class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ This class represents AuthenticatedUsers as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Authorization.py b/github/Authorization.py index ab55c2f9..ed4b208b 100644 --- a/github/Authorization.py +++ b/github/Authorization.py @@ -18,7 +18,7 @@ import github.GithubObject import github.AuthorizationApplication -class Authorization(github.GithubObject.GithubObject): +class Authorization(github.GithubObject.CompletableGithubObject): """ This class represents Authorizations as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/AuthorizationApplication.py b/github/AuthorizationApplication.py index 1093635f..f6e7482d 100644 --- a/github/AuthorizationApplication.py +++ b/github/AuthorizationApplication.py @@ -16,7 +16,7 @@ import github.GithubObject -class AuthorizationApplication(github.GithubObject.GithubObject): +class AuthorizationApplication(github.GithubObject.CompletableGithubObject): """ This class represents AuthorizationApplications as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Branch.py b/github/Branch.py index 95e24c6d..e48e4d08 100644 --- a/github/Branch.py +++ b/github/Branch.py @@ -18,7 +18,7 @@ import github.GithubObject import github.Commit -class Branch(github.GithubObject.BasicGithubObject): +class Branch(github.GithubObject.NonCompletableGithubObject): """ This class represents Branchs as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Commit.py b/github/Commit.py index 7fd1e405..5657b23f 100644 --- a/github/Commit.py +++ b/github/Commit.py @@ -24,7 +24,7 @@ import github.CommitStats import github.CommitComment -class Commit(github.GithubObject.GithubObject): +class Commit(github.GithubObject.CompletableGithubObject): """ This class represents Commits as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/CommitComment.py b/github/CommitComment.py index 1d1e0e22..d73cd0b9 100644 --- a/github/CommitComment.py +++ b/github/CommitComment.py @@ -18,7 +18,7 @@ import github.GithubObject import github.NamedUser -class CommitComment(github.GithubObject.GithubObject): +class CommitComment(github.GithubObject.CompletableGithubObject): """ This class represents CommitComments as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/CommitStats.py b/github/CommitStats.py index 372c8c7f..1258255b 100644 --- a/github/CommitStats.py +++ b/github/CommitStats.py @@ -16,7 +16,7 @@ import github.GithubObject -class CommitStats(github.GithubObject.BasicGithubObject): +class CommitStats(github.GithubObject.NonCompletableGithubObject): """ This class represents CommitStatss as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/CommitStatus.py b/github/CommitStatus.py index 1d4533e2..8991d115 100644 --- a/github/CommitStatus.py +++ b/github/CommitStatus.py @@ -18,7 +18,7 @@ import github.GithubObject import github.NamedUser -class CommitStatus(github.GithubObject.BasicGithubObject): +class CommitStatus(github.GithubObject.NonCompletableGithubObject): """ This class represents CommitStatuss as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Comparison.py b/github/Comparison.py index 5a7c73fd..3816be8e 100644 --- a/github/Comparison.py +++ b/github/Comparison.py @@ -19,7 +19,7 @@ import github.Commit import github.File -class Comparison(github.GithubObject.GithubObject): +class Comparison(github.GithubObject.CompletableGithubObject): """ This class represents Comparisons as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/ContentFile.py b/github/ContentFile.py index 3fb12177..48e0a01e 100644 --- a/github/ContentFile.py +++ b/github/ContentFile.py @@ -16,7 +16,7 @@ import github.GithubObject -class ContentFile(github.GithubObject.GithubObject): +class ContentFile(github.GithubObject.CompletableGithubObject): """ This class represents ContentFiles as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Download.py b/github/Download.py index 29d038c8..2e577745 100644 --- a/github/Download.py +++ b/github/Download.py @@ -16,7 +16,7 @@ import github.GithubObject -class Download(github.GithubObject.GithubObject): +class Download(github.GithubObject.CompletableGithubObject): """ This class represents Downloads as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Event.py b/github/Event.py index 370cce01..42fe8b12 100644 --- a/github/Event.py +++ b/github/Event.py @@ -20,7 +20,7 @@ import github.Repository import github.NamedUser -class Event(github.GithubObject.BasicGithubObject): +class Event(github.GithubObject.NonCompletableGithubObject): """ This class represents Events as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/File.py b/github/File.py index 5406bece..51fc6414 100644 --- a/github/File.py +++ b/github/File.py @@ -16,7 +16,7 @@ import github.GithubObject -class File(github.GithubObject.BasicGithubObject): +class File(github.GithubObject.NonCompletableGithubObject): """ This class represents Files as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Gist.py b/github/Gist.py index f47e41e0..22bd6128 100644 --- a/github/Gist.py +++ b/github/Gist.py @@ -22,7 +22,7 @@ import github.GistFile import github.GistHistoryState -class Gist(github.GithubObject.GithubObject): +class Gist(github.GithubObject.CompletableGithubObject): """ This class represents Gists as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GistComment.py b/github/GistComment.py index a722a373..25d416e1 100644 --- a/github/GistComment.py +++ b/github/GistComment.py @@ -18,7 +18,7 @@ import github.GithubObject import github.NamedUser -class GistComment(github.GithubObject.GithubObject): +class GistComment(github.GithubObject.CompletableGithubObject): """ This class represents GistComments as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GistFile.py b/github/GistFile.py index 796b1acf..30892179 100644 --- a/github/GistFile.py +++ b/github/GistFile.py @@ -16,7 +16,7 @@ import github.GithubObject -class GistFile(github.GithubObject.BasicGithubObject): +class GistFile(github.GithubObject.NonCompletableGithubObject): """ This class represents GistFiles as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GistHistoryState.py b/github/GistHistoryState.py index 132f0726..0c89fc6c 100644 --- a/github/GistHistoryState.py +++ b/github/GistHistoryState.py @@ -19,7 +19,7 @@ import github.NamedUser import github.CommitStats -class GistHistoryState(github.GithubObject.GithubObject): +class GistHistoryState(github.GithubObject.CompletableGithubObject): """ This class represents GistHistoryStates as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitAuthor.py b/github/GitAuthor.py index 9dc39798..cb6b13a5 100644 --- a/github/GitAuthor.py +++ b/github/GitAuthor.py @@ -16,7 +16,7 @@ import github.GithubObject -class GitAuthor(github.GithubObject.BasicGithubObject): +class GitAuthor(github.GithubObject.NonCompletableGithubObject): """ This class represents GitAuthors as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitBlob.py b/github/GitBlob.py index 21c3c6c2..9b5c8b45 100644 --- a/github/GitBlob.py +++ b/github/GitBlob.py @@ -16,7 +16,7 @@ import github.GithubObject -class GitBlob(github.GithubObject.GithubObject): +class GitBlob(github.GithubObject.CompletableGithubObject): """ This class represents GitBlobs as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitCommit.py b/github/GitCommit.py index 391fe2d0..825cbd9d 100644 --- a/github/GitCommit.py +++ b/github/GitCommit.py @@ -19,7 +19,7 @@ import github.GitAuthor import github.GitTree -class GitCommit(github.GithubObject.GithubObject): +class GitCommit(github.GithubObject.CompletableGithubObject): """ This class represents GitCommits as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitObject.py b/github/GitObject.py index 6e5a4a9e..0bd5224c 100644 --- a/github/GitObject.py +++ b/github/GitObject.py @@ -16,7 +16,7 @@ import github.GithubObject -class GitObject(github.GithubObject.BasicGithubObject): +class GitObject(github.GithubObject.NonCompletableGithubObject): """ This class represents GitObjects as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitRef.py b/github/GitRef.py index 8daf11ae..4daa01cb 100644 --- a/github/GitRef.py +++ b/github/GitRef.py @@ -18,7 +18,7 @@ import github.GithubObject import github.GitObject -class GitRef(github.GithubObject.GithubObject): +class GitRef(github.GithubObject.CompletableGithubObject): """ This class represents GitRefs as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitTag.py b/github/GitTag.py index bf24ce37..0c952459 100644 --- a/github/GitTag.py +++ b/github/GitTag.py @@ -19,7 +19,7 @@ import github.GitAuthor import github.GitObject -class GitTag(github.GithubObject.GithubObject): +class GitTag(github.GithubObject.CompletableGithubObject): """ This class represents GitTags as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitTree.py b/github/GitTree.py index de293d84..8f755263 100644 --- a/github/GitTree.py +++ b/github/GitTree.py @@ -18,7 +18,7 @@ import github.GithubObject import github.GitTreeElement -class GitTree(github.GithubObject.GithubObject): +class GitTree(github.GithubObject.CompletableGithubObject): """ This class represents GitTrees as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GitTreeElement.py b/github/GitTreeElement.py index 48b9a023..75c73eab 100644 --- a/github/GitTreeElement.py +++ b/github/GitTreeElement.py @@ -16,7 +16,7 @@ import github.GithubObject -class GitTreeElement(github.GithubObject.BasicGithubObject): +class GitTreeElement(github.GithubObject.NonCompletableGithubObject): """ This class represents GitTreeElements as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/GithubObject.py b/github/GithubObject.py index 554c2228..adfe31c2 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -24,7 +24,7 @@ class _NotSetType: NotSet = _NotSetType() -class BasicGithubObject(object): +class GithubObject(object): def __init__(self, requester, attributes, completed): self._requester = requester self._initAttributes() @@ -42,9 +42,6 @@ class BasicGithubObject(object): self._completeIfNeeded() return self._rawData - def _completeIfNeeded(self): - pass - @staticmethod def _parentUrl(url): return "/".join(url.split("/")[: -1]) @@ -68,9 +65,14 @@ class BasicGithubObject(object): return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ") -class GithubObject(BasicGithubObject): +class NonCompletableGithubObject(GithubObject): + def _completeIfNeeded(self): + pass + + +class CompletableGithubObject(GithubObject): def __init__(self, requester, attributes, completed): - BasicGithubObject.__init__(self, requester, attributes, completed) + GithubObject.__init__(self, requester, attributes, completed) self.__completed = completed def _completeIfNotSet(self, value): diff --git a/github/GitignoreTemplate.py b/github/GitignoreTemplate.py index 10b0b954..0ac378a6 100644 --- a/github/GitignoreTemplate.py +++ b/github/GitignoreTemplate.py @@ -16,7 +16,7 @@ import github.GithubObject -class GitignoreTemplate(github.GithubObject.BasicGithubObject): +class GitignoreTemplate(github.GithubObject.NonCompletableGithubObject): """ This class represents GitignoreTemplates as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Hook.py b/github/Hook.py index c39e18d9..c62eda2d 100644 --- a/github/Hook.py +++ b/github/Hook.py @@ -18,7 +18,7 @@ import github.GithubObject import github.HookResponse -class Hook(github.GithubObject.GithubObject): +class Hook(github.GithubObject.CompletableGithubObject): """ This class represents Hooks as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/HookDescription.py b/github/HookDescription.py index edf470e2..f8c4274c 100644 --- a/github/HookDescription.py +++ b/github/HookDescription.py @@ -16,7 +16,7 @@ import github.GithubObject -class HookDescription(github.GithubObject.BasicGithubObject): +class HookDescription(github.GithubObject.NonCompletableGithubObject): """ This class represents HookDescriptions as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/HookResponse.py b/github/HookResponse.py index 17829816..3d529d5d 100644 --- a/github/HookResponse.py +++ b/github/HookResponse.py @@ -16,7 +16,7 @@ import github.GithubObject -class HookResponse(github.GithubObject.BasicGithubObject): +class HookResponse(github.GithubObject.NonCompletableGithubObject): """ This class represents HookResponses as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Issue.py b/github/Issue.py index 01c8864c..26f3b7a5 100644 --- a/github/Issue.py +++ b/github/Issue.py @@ -25,7 +25,7 @@ import github.IssueComment import github.IssuePullRequest -class Issue(github.GithubObject.GithubObject): +class Issue(github.GithubObject.CompletableGithubObject): """ This class represents Issues as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/IssueComment.py b/github/IssueComment.py index f3e82ba4..26a772fb 100644 --- a/github/IssueComment.py +++ b/github/IssueComment.py @@ -18,7 +18,7 @@ import github.GithubObject import github.NamedUser -class IssueComment(github.GithubObject.GithubObject): +class IssueComment(github.GithubObject.CompletableGithubObject): """ This class represents IssueComments as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/IssueEvent.py b/github/IssueEvent.py index 44c6af8b..870f608b 100644 --- a/github/IssueEvent.py +++ b/github/IssueEvent.py @@ -19,7 +19,7 @@ import github.Issue import github.NamedUser -class IssueEvent(github.GithubObject.GithubObject): +class IssueEvent(github.GithubObject.CompletableGithubObject): """ This class represents IssueEvents as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/IssuePullRequest.py b/github/IssuePullRequest.py index 12c0e713..668f6d7f 100644 --- a/github/IssuePullRequest.py +++ b/github/IssuePullRequest.py @@ -16,7 +16,7 @@ import github.GithubObject -class IssuePullRequest(github.GithubObject.BasicGithubObject): +class IssuePullRequest(github.GithubObject.NonCompletableGithubObject): """ This class represents IssuePullRequests as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Label.py b/github/Label.py index 3106e40e..3c43825e 100644 --- a/github/Label.py +++ b/github/Label.py @@ -18,7 +18,7 @@ import urllib import github.GithubObject -class Label(github.GithubObject.GithubObject): +class Label(github.GithubObject.CompletableGithubObject): """ This class represents Labels as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Milestone.py b/github/Milestone.py index 01cb731e..9b726f2c 100644 --- a/github/Milestone.py +++ b/github/Milestone.py @@ -22,7 +22,7 @@ import github.NamedUser import github.Label -class Milestone(github.GithubObject.GithubObject): +class Milestone(github.GithubObject.CompletableGithubObject): """ This class represents Milestones as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/NamedUser.py b/github/NamedUser.py index 14c69395..f079080e 100644 --- a/github/NamedUser.py +++ b/github/NamedUser.py @@ -24,7 +24,7 @@ import github.Organization import github.Event -class NamedUser(github.GithubObject.GithubObject): +class NamedUser(github.GithubObject.CompletableGithubObject): """ This class represents NamedUsers as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Organization.py b/github/Organization.py index 02b37051..9672591c 100644 --- a/github/Organization.py +++ b/github/Organization.py @@ -23,7 +23,7 @@ import github.Repository import github.NamedUser -class Organization(github.GithubObject.GithubObject): +class Organization(github.GithubObject.CompletableGithubObject): """ This class represents Organizations as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Permissions.py b/github/Permissions.py index 11d2a4a9..1d11462e 100644 --- a/github/Permissions.py +++ b/github/Permissions.py @@ -16,7 +16,7 @@ import github.GithubObject -class Permissions(github.GithubObject.BasicGithubObject): +class Permissions(github.GithubObject.NonCompletableGithubObject): """ This class represents Permissionss as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Plan.py b/github/Plan.py index d609499f..15334a00 100644 --- a/github/Plan.py +++ b/github/Plan.py @@ -16,7 +16,7 @@ import github.GithubObject -class Plan(github.GithubObject.BasicGithubObject): +class Plan(github.GithubObject.NonCompletableGithubObject): """ This class represents Plans as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/PullRequest.py b/github/PullRequest.py index fddc225f..7a91f0ef 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -25,7 +25,7 @@ import github.IssueComment import github.Commit -class PullRequest(github.GithubObject.GithubObject): +class PullRequest(github.GithubObject.CompletableGithubObject): """ This class represents PullRequests as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py index bc5777d8..507cbd9c 100644 --- a/github/PullRequestComment.py +++ b/github/PullRequestComment.py @@ -18,7 +18,7 @@ import github.GithubObject import github.NamedUser -class PullRequestComment(github.GithubObject.GithubObject): +class PullRequestComment(github.GithubObject.CompletableGithubObject): """ This class represents PullRequestComments as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/PullRequestMergeStatus.py b/github/PullRequestMergeStatus.py index edb4a7b5..b6569e27 100644 --- a/github/PullRequestMergeStatus.py +++ b/github/PullRequestMergeStatus.py @@ -16,7 +16,7 @@ import github.GithubObject -class PullRequestMergeStatus(github.GithubObject.BasicGithubObject): +class PullRequestMergeStatus(github.GithubObject.NonCompletableGithubObject): """ This class represents PullRequestMergeStatuss as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/PullRequestPart.py b/github/PullRequestPart.py index 9a78e1bd..728cd41e 100644 --- a/github/PullRequestPart.py +++ b/github/PullRequestPart.py @@ -19,7 +19,7 @@ import github.Repository import github.NamedUser -class PullRequestPart(github.GithubObject.BasicGithubObject): +class PullRequestPart(github.GithubObject.NonCompletableGithubObject): """ This class represents PullRequestParts as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Repository.py b/github/Repository.py index 19518926..7baf15a2 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -47,7 +47,7 @@ import github.Event import github.Legacy -class Repository(github.GithubObject.GithubObject): +class Repository(github.GithubObject.CompletableGithubObject): """ This class represents Repositorys as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/RepositoryKey.py b/github/RepositoryKey.py index f5d19ca3..ef2e742c 100644 --- a/github/RepositoryKey.py +++ b/github/RepositoryKey.py @@ -16,13 +16,13 @@ import github.GithubObject -class RepositoryKey(github.GithubObject.GithubObject): +class RepositoryKey(github.GithubObject.CompletableGithubObject): """ This class represents RepositoryKeys as returned for example by http://developer.github.com/v3/todo """ def __init__(self, requester, attributes, completed, repoUrl): - github.GithubObject.GithubObject.__init__(self, requester, attributes, completed) + github.GithubObject.CompletableGithubObject.__init__(self, requester, attributes, completed) self.__repoUrl = repoUrl @property diff --git a/github/Tag.py b/github/Tag.py index 5f89cdfb..6a04a078 100644 --- a/github/Tag.py +++ b/github/Tag.py @@ -18,7 +18,7 @@ import github.GithubObject import github.Commit -class Tag(github.GithubObject.BasicGithubObject): +class Tag(github.GithubObject.NonCompletableGithubObject): """ This class represents Tags as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/Team.py b/github/Team.py index 5f2c20fd..a184794a 100644 --- a/github/Team.py +++ b/github/Team.py @@ -20,7 +20,7 @@ import github.Repository import github.NamedUser -class Team(github.GithubObject.GithubObject): +class Team(github.GithubObject.CompletableGithubObject): """ This class represents Teams as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/UserKey.py b/github/UserKey.py index 261fcfdc..e226153b 100644 --- a/github/UserKey.py +++ b/github/UserKey.py @@ -16,7 +16,7 @@ import github.GithubObject -class UserKey(github.GithubObject.GithubObject): +class UserKey(github.GithubObject.CompletableGithubObject): """ This class represents UserKeys as returned for example by http://developer.github.com/v3/todo """ diff --git a/github/tests/Issue139.py b/github/tests/Issue139.py index a3f46ec6..e06c002e 100644 --- a/github/tests/Issue139.py +++ b/github/tests/Issue139.py @@ -23,7 +23,7 @@ class Issue139(Framework.TestCase): # https://github.com/jacquev6/PyGithub/issu self.user = self.g.get_user().get_repo("PyGithub").get_issue(139).user def testCompletion(self): - self.assertFalse(self.user._GithubObject__completed) + self.assertFalse(self.user._CompletableGithubObject__completed) self.assertEqual(self.user.name, "Ian Ozsvald") - self.assertTrue(self.user._GithubObject__completed) + self.assertTrue(self.user._CompletableGithubObject__completed) self.assertEqual(self.user.plan, None) diff --git a/github/tests/RawData.py b/github/tests/RawData.py index dd950086..cd81dd35 100644 --- a/github/tests/RawData.py +++ b/github/tests/RawData.py @@ -68,14 +68,14 @@ class RawData(Framework.TestCase): def testCompletedObject(self): user = self.g.get_user("jacquev6") - self.assertTrue(user._GithubObject__completed) + self.assertTrue(user._CompletableGithubObject__completed) self.assertEqual(user.raw_data, RawData.jacquev6RawData) def testNotYetCompletedObject(self): user = self.g.get_user().get_repo("PyGithub").owner - self.assertFalse(user._GithubObject__completed) + self.assertFalse(user._CompletableGithubObject__completed) self.assertEqual(user.raw_data, RawData.jacquev6RawData) - self.assertTrue(user._GithubObject__completed) + self.assertTrue(user._CompletableGithubObject__completed) def testNonCompletableObject(self): plan = self.g.get_user().plan From 3af543a1fed27b3a39200da02a91ef2513f5482f Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 14 Mar 2013 12:32:46 +0100 Subject: [PATCH 3/5] Add a way to create an object from raw data (Issue #144) --- github/MainClass.py | 9 +++++++++ github/tests/RawData.py | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/github/MainClass.py b/github/MainClass.py index cf38e7a2..5760c3c9 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -278,3 +278,12 @@ class Github(object): None ) return GitignoreTemplate.GitignoreTemplate(self.__requester, attributes, completed=True) + + def create_from_raw_data(self, klass, raw_data): + """ + Creates an object from raw_data previously obtained by myObject.raw_data + :param klass: the class of the object to create + :param raw_data: dict + :rtype: instance of class ``klass`` + """ + return klass(self.__requester, raw_data, completed=True) diff --git a/github/tests/RawData.py b/github/tests/RawData.py index cd81dd35..53b8e470 100644 --- a/github/tests/RawData.py +++ b/github/tests/RawData.py @@ -15,6 +15,8 @@ import Framework +import github.NamedUser + class RawData(Framework.TestCase): jacquev6RawData = { u'disk_usage': 13812, @@ -80,3 +82,8 @@ class RawData(Framework.TestCase): def testNonCompletableObject(self): plan = self.g.get_user().plan self.assertEqual(plan.raw_data, RawData.planRawData) + + def testCreateObjectFromRawData(self): + user = self.g.create_from_raw_data(github.NamedUser.NamedUser, RawData.jacquev6RawData) + self.assertEqual(user._CompletableGithubObject__completed, True) + self.assertEqual(user.name, "Vincent Jacques") From ddcabfa2683672073285ba7adb3661a0bb4f4362 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 14 Mar 2013 12:40:25 +0100 Subject: [PATCH 4/5] ReadMe --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 42767b0d..b6d57fa4 100644 --- a/README.rst +++ b/README.rst @@ -11,10 +11,12 @@ What's new? =========== `Version 1.13.0 `_ (March 15th, 2013) (`ksookocheff-va `_'s edition) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + All issues solved in this version were reported by `ksookocheff-va `_. Thank you! * `Fix `_ for Python 3 on case-insensitive file-systems +* `Expose `_ raw data returned by Github for all objects * `Add `_ a property ``Github.per_page`` (and a parameter to the constructor) to change the number of items requested in paginated requests Documentation From 040f024cf4bbbebe4dfe35d29854f398a0e2117e Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Tue, 19 Mar 2013 22:30:54 +0100 Subject: [PATCH 5/5] Fix doc --- github/MainClass.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github/MainClass.py b/github/MainClass.py index 5760c3c9..d8a04711 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -281,7 +281,8 @@ class Github(object): def create_from_raw_data(self, klass, raw_data): """ - Creates an object from raw_data previously obtained by myObject.raw_data + Creates an object from raw_data previously obtained by ``myObject.raw_data`` + :param klass: the class of the object to create :param raw_data: dict :rtype: instance of class ``klass``