diff --git a/.gitignore b/.gitignore index 98aa8eff..6ff70a1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ ############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -28,3 +29,6 @@ GithubCredentials.py /PyGithub.egg-info/ /.coverage /developer.github.com/ + +*.cfg +*.bat diff --git a/README.rst b/README.rst index f96d4849..88c8fa06 100644 --- a/README.rst +++ b/README.rst @@ -14,6 +14,7 @@ What's new? * Implement ``Github.get_repos`` to get all public repositories * Implement ``NamedUser.has_in_following`` +* Technical change: HTTP headers are now stored in retrieved objects. This is a base for new functionalities. Thank you `akfish `_ for the pull request * Use the new URL to fork gists (minor change) * Use the new URL to test hooks (minor change) diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py index a92a7813..e035f9a1 100644 --- a/github/AuthenticatedUser.py +++ b/github/AuthenticatedUser.py @@ -5,6 +5,7 @@ # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -348,7 +349,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Authorization.Authorization(self._requester, data, completed=True) + return github.Authorization.Authorization(self._requester, headers, data, completed=True) def create_fork(self, repo): """ @@ -363,7 +364,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, None ) - return github.Repository.Repository(self._requester, data, completed=True) + return github.Repository.Repository(self._requester, headers, data, completed=True) def create_gist(self, public, files, description=github.GithubObject.NotSet): """ @@ -388,7 +389,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Gist.Gist(self._requester, data, completed=True) + return github.Gist.Gist(self._requester, headers, data, completed=True) def create_key(self, title, key): """ @@ -409,7 +410,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.UserKey.UserKey(self._requester, data, completed=True) + return github.UserKey.UserKey(self._requester, headers, data, completed=True) def create_repo(self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, auto_init=github.GithubObject.NotSet, gitignore_template=github.GithubObject.NotSet): """ @@ -459,7 +460,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Repository.Repository(self._requester, data, completed=True) + return github.Repository.Repository(self._requester, headers, data, completed=True) def edit(self, name=github.GithubObject.NotSet, email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, location=github.GithubObject.NotSet, hireable=github.GithubObject.NotSet, bio=github.GithubObject.NotSet): """ @@ -516,7 +517,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, None ) - return github.Authorization.Authorization(self._requester, data, completed=True) + return github.Authorization.Authorization(self._requester, headers, data, completed=True) def get_authorizations(self): """ @@ -680,7 +681,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, None ) - return github.UserKey.UserKey(self._requester, data, completed=True) + return github.UserKey.UserKey(self._requester, headers, data, completed=True) def get_keys(self): """ @@ -707,7 +708,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, None ) - return github.Notification.Notification(self._requester, data, completed=True) + return github.Notification.Notification(self._requester, headers, data, completed=True) def get_notifications(self, all=github.GithubObject.NotSet, participating=github.GithubObject.NotSet): """ @@ -771,7 +772,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): None, None ) - return github.Repository.Repository(self._requester, data, completed=True) + return github.Repository.Repository(self._requester, headers, data, completed=True) def get_repos(self, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet): """ @@ -1061,7 +1062,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject): self._owned_private_repos = attributes["owned_private_repos"] if "plan" in attributes: # pragma no branch assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"] - self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, attributes["plan"], completed=False) + self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False) if "private_gists" in attributes: # pragma no branch assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"] self._private_gists = attributes["private_gists"] diff --git a/github/Authorization.py b/github/Authorization.py index 14cc1350..2289fd34 100644 --- a/github/Authorization.py +++ b/github/Authorization.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -165,7 +166,7 @@ class Authorization(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "app" in attributes: # pragma no branch assert attributes["app"] is None or isinstance(attributes["app"], dict), attributes["app"] - self._app = None if attributes["app"] is None else github.AuthorizationApplication.AuthorizationApplication(self._requester, attributes["app"], completed=False) + self._app = None if attributes["app"] is None else github.AuthorizationApplication.AuthorizationApplication(self._requester, self._headers, attributes["app"], completed=False) if "created_at" in attributes: # pragma no branch assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] self._created_at = self._parseDatetime(attributes["created_at"]) diff --git a/github/AuthorizationApplication.py b/github/AuthorizationApplication.py index 392ec78c..8f38bc14 100644 --- a/github/AuthorizationApplication.py +++ b/github/AuthorizationApplication.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Branch.py b/github/Branch.py index 11f074d5..9e761826 100644 --- a/github/Branch.py +++ b/github/Branch.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # @@ -55,7 +56,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "commit" in attributes: # pragma no branch assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"] - self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, attributes["commit"], completed=False) + self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False) if "name" in attributes: # pragma no branch assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] self._name = attributes["name"] diff --git a/github/Commit.py b/github/Commit.py index de9da2d1..5e909213 100644 --- a/github/Commit.py +++ b/github/Commit.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # @@ -132,7 +133,7 @@ class Commit(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.CommitComment.CommitComment(self._requester, data, completed=True) + return github.CommitComment.CommitComment(self._requester, headers, data, completed=True) def create_status(self, state, target_url=github.GithubObject.NotSet, description=github.GithubObject.NotSet): """ @@ -158,7 +159,7 @@ class Commit(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.CommitStatus.CommitStatus(self._requester, data, completed=True) + return github.CommitStatus.CommitStatus(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -201,23 +202,23 @@ class Commit(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch assert attributes["author"] is None or isinstance(attributes["author"], dict), attributes["author"] - self._author = None if attributes["author"] is None else github.NamedUser.NamedUser(self._requester, attributes["author"], completed=False) + self._author = None if attributes["author"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["author"], completed=False) if "commit" in attributes: # pragma no branch assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"] - self._commit = None if attributes["commit"] is None else github.GitCommit.GitCommit(self._requester, attributes["commit"], completed=False) + self._commit = None if attributes["commit"] is None else github.GitCommit.GitCommit(self._requester, self._headers, attributes["commit"], completed=False) if "committer" in attributes: # pragma no branch assert attributes["committer"] is None or isinstance(attributes["committer"], dict), attributes["committer"] - self._committer = None if attributes["committer"] is None else github.NamedUser.NamedUser(self._requester, attributes["committer"], completed=False) + self._committer = None if attributes["committer"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["committer"], completed=False) if "files" in attributes: # pragma no branch assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"]), attributes["files"] self._files = None if attributes["files"] is None else [ - github.File.File(self._requester, element, completed=False) + github.File.File(self._requester, self._headers, element, completed=False) for element in attributes["files"] ] if "parents" in attributes: # pragma no branch assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"] self._parents = None if attributes["parents"] is None else [ - Commit(self._requester, element, completed=False) + Commit(self._requester, self._headers, element, completed=False) for element in attributes["parents"] ] if "sha" in attributes: # pragma no branch @@ -225,7 +226,7 @@ class Commit(github.GithubObject.CompletableGithubObject): self._sha = attributes["sha"] if "stats" in attributes: # pragma no branch assert attributes["stats"] is None or isinstance(attributes["stats"], dict), attributes["stats"] - self._stats = None if attributes["stats"] is None else github.CommitStats.CommitStats(self._requester, attributes["stats"], completed=False) + self._stats = None if attributes["stats"] is None else github.CommitStats.CommitStats(self._requester, self._headers, attributes["stats"], completed=False) if "url" in attributes: # pragma no branch assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] self._url = attributes["url"] diff --git a/github/CommitComment.py b/github/CommitComment.py index 30f1df3a..55c2cf86 100644 --- a/github/CommitComment.py +++ b/github/CommitComment.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -197,4 +198,4 @@ class CommitComment(github.GithubObject.CompletableGithubObject): self._url = attributes["url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/CommitStats.py b/github/CommitStats.py index 1be6a1d4..49f40778 100644 --- a/github/CommitStats.py +++ b/github/CommitStats.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/CommitStatus.py b/github/CommitStatus.py index 122c55c4..d08e0274 100644 --- a/github/CommitStatus.py +++ b/github/CommitStatus.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -97,7 +98,7 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject): self._created_at = self._parseDatetime(attributes["created_at"]) if "creator" in attributes: # pragma no branch assert attributes["creator"] is None or isinstance(attributes["creator"], dict), attributes["creator"] - self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, attributes["creator"], completed=False) + self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["creator"], completed=False) if "description" in attributes: # pragma no branch assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] self._description = attributes["description"] diff --git a/github/Comparison.py b/github/Comparison.py index a67cb5ae..f5f66bc1 100644 --- a/github/Comparison.py +++ b/github/Comparison.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -150,14 +151,14 @@ class Comparison(github.GithubObject.CompletableGithubObject): self._ahead_by = attributes["ahead_by"] if "base_commit" in attributes: # pragma no branch assert attributes["base_commit"] is None or isinstance(attributes["base_commit"], dict), attributes["base_commit"] - self._base_commit = None if attributes["base_commit"] is None else github.Commit.Commit(self._requester, attributes["base_commit"], completed=False) + self._base_commit = None if attributes["base_commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["base_commit"], completed=False) if "behind_by" in attributes: # pragma no branch assert attributes["behind_by"] is None or isinstance(attributes["behind_by"], (int, long)), attributes["behind_by"] self._behind_by = attributes["behind_by"] if "commits" in attributes: # pragma no branch assert attributes["commits"] is None or all(isinstance(element, dict) for element in attributes["commits"]), attributes["commits"] self._commits = None if attributes["commits"] is None else [ - github.Commit.Commit(self._requester, element, completed=False) + github.Commit.Commit(self._requester, self._headers, element, completed=False) for element in attributes["commits"] ] if "diff_url" in attributes: # pragma no branch @@ -166,7 +167,7 @@ class Comparison(github.GithubObject.CompletableGithubObject): if "files" in attributes: # pragma no branch assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"]), attributes["files"] self._files = None if attributes["files"] is None else [ - github.File.File(self._requester, element, completed=False) + github.File.File(self._requester, self._headers, element, completed=False) for element in attributes["files"] ] if "html_url" in attributes: # pragma no branch diff --git a/github/ContentFile.py b/github/ContentFile.py index fda1d3d6..03818842 100644 --- a/github/ContentFile.py +++ b/github/ContentFile.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Download.py b/github/Download.py index 7555a8c3..86b7ae44 100644 --- a/github/Download.py +++ b/github/Download.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Event.py b/github/Event.py index 60e7c863..20351025 100644 --- a/github/Event.py +++ b/github/Event.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # @@ -105,7 +106,7 @@ class Event(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch assert attributes["actor"] is None or isinstance(attributes["actor"], dict), attributes["actor"] - self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, attributes["actor"], completed=False) + self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["actor"], completed=False) if "created_at" in attributes: # pragma no branch assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str, unicode)), attributes["created_at"] self._created_at = self._parseDatetime(attributes["created_at"]) @@ -114,7 +115,7 @@ class Event(github.GithubObject.NonCompletableGithubObject): self._id = attributes["id"] if "org" in attributes: # pragma no branch assert attributes["org"] is None or isinstance(attributes["org"], dict), attributes["org"] - self._org = None if attributes["org"] is None else github.Organization.Organization(self._requester, attributes["org"], completed=False) + self._org = None if attributes["org"] is None else github.Organization.Organization(self._requester, self._headers, attributes["org"], completed=False) if "payload" in attributes: # pragma no branch assert attributes["payload"] is None or isinstance(attributes["payload"], dict), attributes["payload"] self._payload = attributes["payload"] @@ -123,7 +124,7 @@ class Event(github.GithubObject.NonCompletableGithubObject): self._public = attributes["public"] if "repo" in attributes: # pragma no branch assert attributes["repo"] is None or isinstance(attributes["repo"], dict), attributes["repo"] - self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, attributes["repo"], completed=False) + self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repo"], completed=False) if "type" in attributes: # pragma no branch assert attributes["type"] is None or isinstance(attributes["type"], (str, unicode)), attributes["type"] self._type = attributes["type"] diff --git a/github/File.py b/github/File.py index 538fde6b..6adaae8a 100644 --- a/github/File.py +++ b/github/File.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Gist.py b/github/Gist.py index be9465f6..a1497685 100644 --- a/github/Gist.py +++ b/github/Gist.py @@ -5,6 +5,7 @@ # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -174,7 +175,7 @@ class Gist(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.GistComment.GistComment(self._requester, data, completed=True) + return github.GistComment.GistComment(self._requester, headers, data, completed=True) def create_fork(self): """ @@ -187,7 +188,7 @@ class Gist(github.GithubObject.CompletableGithubObject): None, None ) - return Gist(self._requester, data, completed=True) + return Gist(self._requester, headers, data, completed=True) def delete(self): """ @@ -236,7 +237,7 @@ class Gist(github.GithubObject.CompletableGithubObject): None, None ) - return github.GistComment.GistComment(self._requester, data, completed=True) + return github.GistComment.GistComment(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -317,12 +318,12 @@ class Gist(github.GithubObject.CompletableGithubObject): if "files" in attributes: # pragma no branch assert attributes["files"] is None or all(isinstance(element, dict) for element in attributes["files"].itervalues()), attributes["files"] self._files = None if attributes["files"] is None else dict( - (key, github.GistFile.GistFile(self._requester, element, completed=False)) + (key, github.GistFile.GistFile(self._requester, self._headers, element, completed=False)) for key, element in attributes["files"].iteritems() ) if "fork_of" in attributes: # pragma no branch assert attributes["fork_of"] is None or isinstance(attributes["fork_of"], dict), attributes["fork_of"] - self._fork_of = None if attributes["fork_of"] is None else Gist(self._requester, attributes["fork_of"], completed=False) + self._fork_of = None if attributes["fork_of"] is None else Gist(self._requester, self._headers, attributes["fork_of"], completed=False) if "forks" in attributes: # pragma no branch assert attributes["forks"] is None or all(isinstance(element, dict) for element in attributes["forks"]), attributes["forks"] self._forks = None if attributes["forks"] is None else [ @@ -338,7 +339,7 @@ class Gist(github.GithubObject.CompletableGithubObject): if "history" in attributes: # pragma no branch assert attributes["history"] is None or all(isinstance(element, dict) for element in attributes["history"]), attributes["history"] self._history = None if attributes["history"] is None else [ - github.GistHistoryState.GistHistoryState(self._requester, element, completed=False) + github.GistHistoryState.GistHistoryState(self._requester, self._headers, element, completed=False) for element in attributes["history"] ] if "html_url" in attributes: # pragma no branch @@ -358,4 +359,4 @@ class Gist(github.GithubObject.CompletableGithubObject): self._url = attributes["url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/GistComment.py b/github/GistComment.py index 2bb28abd..6c7e2461 100644 --- a/github/GistComment.py +++ b/github/GistComment.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -137,4 +138,4 @@ class GistComment(github.GithubObject.CompletableGithubObject): self._url = attributes["url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/GistFile.py b/github/GistFile.py index a153c7ba..96c8ee27 100644 --- a/github/GistFile.py +++ b/github/GistFile.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/GistHistoryState.py b/github/GistHistoryState.py index 75f78535..bc24d5c0 100644 --- a/github/GistHistoryState.py +++ b/github/GistHistoryState.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -84,7 +85,7 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "change_status" in attributes: # pragma no branch assert attributes["change_status"] is None or isinstance(attributes["change_status"], dict), attributes["change_status"] - self._change_status = None if attributes["change_status"] is None else github.CommitStats.CommitStats(self._requester, attributes["change_status"], completed=False) + self._change_status = None if attributes["change_status"] is None else github.CommitStats.CommitStats(self._requester, self._headers, attributes["change_status"], completed=False) if "committed_at" in attributes: # pragma no branch assert attributes["committed_at"] is None or isinstance(attributes["committed_at"], (str, unicode)), attributes["committed_at"] self._committed_at = self._parseDatetime(attributes["committed_at"]) @@ -93,7 +94,7 @@ class GistHistoryState(github.GithubObject.CompletableGithubObject): self._url = attributes["url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) if "version" in attributes: # pragma no branch assert attributes["version"] is None or isinstance(attributes["version"], (str, unicode)), attributes["version"] self._version = attributes["version"] diff --git a/github/GitAuthor.py b/github/GitAuthor.py index dd409dea..e56ce94d 100644 --- a/github/GitAuthor.py +++ b/github/GitAuthor.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/GitBlob.py b/github/GitBlob.py index ffb12f98..8f105682 100644 --- a/github/GitBlob.py +++ b/github/GitBlob.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/GitCommit.py b/github/GitCommit.py index c87ca26b..ffdc6d5a 100644 --- a/github/GitCommit.py +++ b/github/GitCommit.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -106,17 +107,17 @@ class GitCommit(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch assert attributes["author"] is None or isinstance(attributes["author"], dict), attributes["author"] - self._author = None if attributes["author"] is None else github.GitAuthor.GitAuthor(self._requester, attributes["author"], completed=False) + self._author = None if attributes["author"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["author"], completed=False) if "committer" in attributes: # pragma no branch assert attributes["committer"] is None or isinstance(attributes["committer"], dict), attributes["committer"] - self._committer = None if attributes["committer"] is None else github.GitAuthor.GitAuthor(self._requester, attributes["committer"], completed=False) + self._committer = None if attributes["committer"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["committer"], completed=False) if "message" in attributes: # pragma no branch assert attributes["message"] is None or isinstance(attributes["message"], (str, unicode)), attributes["message"] self._message = attributes["message"] if "parents" in attributes: # pragma no branch assert attributes["parents"] is None or all(isinstance(element, dict) for element in attributes["parents"]), attributes["parents"] self._parents = None if attributes["parents"] is None else [ - GitCommit(self._requester, element, completed=False) + GitCommit(self._requester, self._headers, element, completed=False) for element in attributes["parents"] ] if "sha" in attributes: # pragma no branch @@ -124,7 +125,7 @@ class GitCommit(github.GithubObject.CompletableGithubObject): self._sha = attributes["sha"] if "tree" in attributes: # pragma no branch assert attributes["tree"] is None or isinstance(attributes["tree"], dict), attributes["tree"] - self._tree = None if attributes["tree"] is None else github.GitTree.GitTree(self._requester, attributes["tree"], completed=False) + self._tree = None if attributes["tree"] is None else github.GitTree.GitTree(self._requester, self._headers, attributes["tree"], completed=False) if "url" in attributes: # pragma no branch assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] self._url = attributes["url"] diff --git a/github/GitObject.py b/github/GitObject.py index 2d29b437..a7314641 100644 --- a/github/GitObject.py +++ b/github/GitObject.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/GitRef.py b/github/GitRef.py index 44d177b8..a666156b 100644 --- a/github/GitRef.py +++ b/github/GitRef.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -99,7 +100,7 @@ class GitRef(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "object" in attributes: # pragma no branch assert attributes["object"] is None or isinstance(attributes["object"], dict), attributes["object"] - self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, attributes["object"], completed=False) + self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, self._headers, attributes["object"], completed=False) if "ref" in attributes: # pragma no branch assert attributes["ref"] is None or isinstance(attributes["ref"], (str, unicode)), attributes["ref"] self._ref = attributes["ref"] diff --git a/github/GitTag.py b/github/GitTag.py index 980328a0..564b6b86 100644 --- a/github/GitTag.py +++ b/github/GitTag.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -96,7 +97,7 @@ class GitTag(github.GithubObject.CompletableGithubObject): self._message = attributes["message"] if "object" in attributes: # pragma no branch assert attributes["object"] is None or isinstance(attributes["object"], dict), attributes["object"] - self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, attributes["object"], completed=False) + self._object = None if attributes["object"] is None else github.GitObject.GitObject(self._requester, self._headers, attributes["object"], completed=False) if "sha" in attributes: # pragma no branch assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] self._sha = attributes["sha"] @@ -105,7 +106,7 @@ class GitTag(github.GithubObject.CompletableGithubObject): self._tag = attributes["tag"] if "tagger" in attributes: # pragma no branch assert attributes["tagger"] is None or isinstance(attributes["tagger"], dict), attributes["tagger"] - self._tagger = None if attributes["tagger"] is None else github.GitAuthor.GitAuthor(self._requester, attributes["tagger"], completed=False) + self._tagger = None if attributes["tagger"] is None else github.GitAuthor.GitAuthor(self._requester, self._headers, attributes["tagger"], completed=False) if "url" in attributes: # pragma no branch assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] self._url = attributes["url"] diff --git a/github/GitTree.py b/github/GitTree.py index 38c696b8..b06c5e82 100644 --- a/github/GitTree.py +++ b/github/GitTree.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -73,7 +74,7 @@ class GitTree(github.GithubObject.CompletableGithubObject): if "tree" in attributes: # pragma no branch assert attributes["tree"] is None or all(isinstance(element, dict) for element in attributes["tree"]), attributes["tree"] self._tree = None if attributes["tree"] is None else [ - github.GitTreeElement.GitTreeElement(self._requester, element, completed=False) + github.GitTreeElement.GitTreeElement(self._requester, self._headers, element, completed=False) for element in attributes["tree"] ] if "url" in attributes: # pragma no branch diff --git a/github/GitTreeElement.py b/github/GitTreeElement.py index bf361be0..e7ae76bb 100644 --- a/github/GitTreeElement.py +++ b/github/GitTreeElement.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/GithubObject.py b/github/GithubObject.py index 8178d8e7..fcf36c29 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -38,11 +39,29 @@ class GithubObject(object): """ Base class for all classes representing objects returned by the API. """ - def __init__(self, requester, attributes, completed): + + ''' + A global debug flag to enable header validation by requester for all objects + ''' + CHECK_AFTER_INIT_FLAG = False + + @classmethod + def setCheckAfterInitFlag(cls, flag): + cls.CHECK_AFTER_INIT_FLAG = flag + + def __init__(self, requester, headers, attributes, completed): self._requester = requester + # Make sure headers are signed before any operations on attributes + # Object creatation requires headers as parameter + self._headers = headers; self._initAttributes() self._storeAndUseAttributes(attributes) + # Ask requester to do some checking, for debug and test purpose + # Since it's most handy to access and kinda all-knowing + if (self.CHECK_AFTER_INIT_FLAG): + requester.check_me(self); + def _storeAndUseAttributes(self, attributes): self._useAttributes(attributes) self._rawData = attributes @@ -84,8 +103,8 @@ class NonCompletableGithubObject(GithubObject): class CompletableGithubObject(GithubObject): - def __init__(self, requester, attributes, completed): - GithubObject.__init__(self, requester, attributes, completed) + def __init__(self, requester, headers, attributes, completed): + GithubObject.__init__(self, requester, headers, attributes, completed) self.__completed = completed def _completeIfNotSet(self, value): @@ -103,5 +122,6 @@ class CompletableGithubObject(GithubObject): None, None ) + self._headers = headers self._storeAndUseAttributes(data) self.__completed = True diff --git a/github/GitignoreTemplate.py b/github/GitignoreTemplate.py index a1b96d7c..a8a7022f 100644 --- a/github/GitignoreTemplate.py +++ b/github/GitignoreTemplate.py @@ -3,6 +3,7 @@ ############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Hook.py b/github/Hook.py index 922f718a..721bdd7a 100644 --- a/github/Hook.py +++ b/github/Hook.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -195,7 +196,7 @@ class Hook(github.GithubObject.CompletableGithubObject): self._id = attributes["id"] if "last_response" in attributes: # pragma no branch assert attributes["last_response"] is None or isinstance(attributes["last_response"], dict), attributes["last_response"] - self._last_response = None if attributes["last_response"] is None else github.HookResponse.HookResponse(self._requester, attributes["last_response"], completed=False) + self._last_response = None if attributes["last_response"] is None else github.HookResponse.HookResponse(self._requester, self._headers, attributes["last_response"], completed=False) if "name" in attributes: # pragma no branch assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] self._name = attributes["name"] diff --git a/github/HookDescription.py b/github/HookDescription.py index 766cbfc7..5653492b 100644 --- a/github/HookDescription.py +++ b/github/HookDescription.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/HookResponse.py b/github/HookResponse.py index 87dc0ac0..41e242b3 100644 --- a/github/HookResponse.py +++ b/github/HookResponse.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Issue.py b/github/Issue.py index b25c5e0b..b2d5b672 100644 --- a/github/Issue.py +++ b/github/Issue.py @@ -6,6 +6,7 @@ # Copyright 2012 Philip Kimmey # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Stuart Glaser # # Copyright 2013 Vincent Jacques # # # @@ -222,7 +223,7 @@ class Issue(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.IssueComment.IssueComment(self._requester, data, completed=True) + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) def delete_labels(self): """ @@ -287,7 +288,7 @@ class Issue(github.GithubObject.CompletableGithubObject): None, None ) - return github.IssueComment.IssueComment(self._requester, data, completed=True) + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -381,7 +382,7 @@ class Issue(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "assignee" in attributes: # pragma no branch assert attributes["assignee"] is None or isinstance(attributes["assignee"], dict), attributes["assignee"] - self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, attributes["assignee"], completed=False) + self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["assignee"], completed=False) if "body" in attributes: # pragma no branch assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] self._body = attributes["body"] @@ -390,7 +391,7 @@ class Issue(github.GithubObject.CompletableGithubObject): self._closed_at = self._parseDatetime(attributes["closed_at"]) if "closed_by" in attributes: # pragma no branch assert attributes["closed_by"] is None or isinstance(attributes["closed_by"], dict), attributes["closed_by"] - self._closed_by = None if attributes["closed_by"] is None else github.NamedUser.NamedUser(self._requester, attributes["closed_by"], completed=False) + self._closed_by = None if attributes["closed_by"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["closed_by"], completed=False) if "comments" in attributes: # pragma no branch assert attributes["comments"] is None or isinstance(attributes["comments"], (int, long)), attributes["comments"] self._comments = attributes["comments"] @@ -406,21 +407,21 @@ class Issue(github.GithubObject.CompletableGithubObject): if "labels" in attributes: # pragma no branch assert attributes["labels"] is None or all(isinstance(element, dict) for element in attributes["labels"]), attributes["labels"] self._labels = None if attributes["labels"] is None else [ - github.Label.Label(self._requester, element, completed=False) + github.Label.Label(self._requester, self._headers, element, completed=False) for element in attributes["labels"] ] if "milestone" in attributes: # pragma no branch assert attributes["milestone"] is None or isinstance(attributes["milestone"], dict), attributes["milestone"] - self._milestone = None if attributes["milestone"] is None else github.Milestone.Milestone(self._requester, attributes["milestone"], completed=False) + self._milestone = None if attributes["milestone"] is None else github.Milestone.Milestone(self._requester, self._headers, attributes["milestone"], completed=False) if "number" in attributes: # pragma no branch assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"] self._number = attributes["number"] if "pull_request" in attributes: # pragma no branch assert attributes["pull_request"] is None or isinstance(attributes["pull_request"], dict), attributes["pull_request"] - self._pull_request = None if attributes["pull_request"] is None else github.IssuePullRequest.IssuePullRequest(self._requester, attributes["pull_request"], completed=False) + self._pull_request = None if attributes["pull_request"] is None else github.IssuePullRequest.IssuePullRequest(self._requester, self._headers, attributes["pull_request"], completed=False) if "repository" in attributes: # pragma no branch assert attributes["repository"] is None or isinstance(attributes["repository"], dict), attributes["repository"] - self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, attributes["repository"], completed=False) + self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repository"], completed=False) if "state" in attributes: # pragma no branch assert attributes["state"] is None or isinstance(attributes["state"], (str, unicode)), attributes["state"] self._state = attributes["state"] @@ -435,4 +436,4 @@ class Issue(github.GithubObject.CompletableGithubObject): self._url = attributes["url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/IssueComment.py b/github/IssueComment.py index 5e9e5099..5a3c62da 100644 --- a/github/IssueComment.py +++ b/github/IssueComment.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Michael Stead # # Copyright 2013 Vincent Jacques # # # @@ -150,4 +151,4 @@ class IssueComment(github.GithubObject.CompletableGithubObject): self._html_url = attributes["html_url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/IssueEvent.py b/github/IssueEvent.py index 431ce2ad..aca4cdf8 100644 --- a/github/IssueEvent.py +++ b/github/IssueEvent.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -102,7 +103,7 @@ class IssueEvent(github.GithubObject.CompletableGithubObject): def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch assert attributes["actor"] is None or isinstance(attributes["actor"], dict), attributes["actor"] - self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, attributes["actor"], completed=False) + self._actor = None if attributes["actor"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["actor"], completed=False) if "commit_id" in attributes: # pragma no branch assert attributes["commit_id"] is None or isinstance(attributes["commit_id"], (str, unicode)), attributes["commit_id"] self._commit_id = attributes["commit_id"] @@ -117,7 +118,7 @@ class IssueEvent(github.GithubObject.CompletableGithubObject): self._id = attributes["id"] if "issue" in attributes: # pragma no branch assert attributes["issue"] is None or isinstance(attributes["issue"], dict), attributes["issue"] - self._issue = None if attributes["issue"] is None else github.Issue.Issue(self._requester, attributes["issue"], completed=False) + self._issue = None if attributes["issue"] is None else github.Issue.Issue(self._requester, self._headers, attributes["issue"], completed=False) if "url" in attributes: # pragma no branch assert attributes["url"] is None or isinstance(attributes["url"], (str, unicode)), attributes["url"] self._url = attributes["url"] diff --git a/github/IssuePullRequest.py b/github/IssuePullRequest.py index cdc1b44b..ae7e6b6c 100644 --- a/github/IssuePullRequest.py +++ b/github/IssuePullRequest.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Label.py b/github/Label.py index e2d42335..b3c75501 100644 --- a/github/Label.py +++ b/github/Label.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # diff --git a/github/Legacy.py b/github/Legacy.py index 599ca605..1ed760e2 100644 --- a/github/Legacy.py +++ b/github/Legacy.py @@ -5,6 +5,7 @@ # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -61,8 +62,9 @@ class PaginatedList(github.PaginatedList.PaginatedListBase): None ) self.__continue = len(data[self.__key]) > 0 + return [ - self.__contentClass(self.__requester, self.__convert(element), completed=False) + self.__contentClass(self.__requester, headers, self.__convert(element), completed=False) for element in data[self.__key] ] diff --git a/github/MainClass.py b/github/MainClass.py index 82d07b93..ae1f612f 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -2,6 +2,7 @@ ############################ Copyrights and license ############################ # # +# Copyright 2013 AKFish # # Copyright 2013 Ed Jackson # # Copyright 2013 Jonathan J Hunt # # Copyright 2013 Peter Golm # @@ -139,7 +140,7 @@ class Github(object): """ assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login if login is github.GithubObject.NotSet: - return AuthenticatedUser.AuthenticatedUser(self.__requester, {"url": "/user"}, completed=False) + return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False) else: headers, data = self.__requester.requestJsonAndCheck( "GET", @@ -147,7 +148,7 @@ class Github(object): None, None ) - return github.NamedUser.NamedUser(self.__requester, data, completed=True) + return github.NamedUser.NamedUser(self.__requester, headers, data, completed=True) def get_users(self, since=github.GithubObject.NotSet): """ @@ -179,7 +180,7 @@ class Github(object): None, None ) - return github.Organization.Organization(self.__requester, data, completed=True) + return github.Organization.Organization(self.__requester, headers, data, completed=True) def get_repo(self, full_name): """ @@ -193,7 +194,7 @@ class Github(object): None, None ) - return Repository.Repository(self.__requester, data, completed=True) + return Repository.Repository(self.__requester, headers, data, completed=True) def get_repos(self, since=github.GithubObject.NotSet): """ @@ -225,7 +226,7 @@ class Github(object): None, None ) - return github.Gist.Gist(self.__requester, data, completed=True) + return github.Gist.Gist(self.__requester, headers, data, completed=True) def get_gists(self): """ @@ -287,7 +288,7 @@ class Github(object): None, None ) - return github.NamedUser.NamedUser(self.__requester, Legacy.convertUser(data["user"]), completed=False) + return github.NamedUser.NamedUser(self.__requester, headers, Legacy.convertUser(data["user"]), completed=False) def render_markdown(self, text, context=github.GithubObject.NotSet): """ @@ -323,7 +324,7 @@ class Github(object): None, None ) - return [HookDescription.HookDescription(self.__requester, attributes, completed=True) for attributes in data] + return [HookDescription.HookDescription(self.__requester, headers, attributes, completed=True) for attributes in data] def get_gitignore_templates(self): """ @@ -350,9 +351,9 @@ class Github(object): None, None ) - return GitignoreTemplate.GitignoreTemplate(self.__requester, attributes, completed=True) + return GitignoreTemplate.GitignoreTemplate(self.__requester, headers, attributes, completed=True) - def create_from_raw_data(self, klass, raw_data): + def create_from_raw_data(self, klass, raw_data, headers={}): """ Creates an object from raw_data previously obtained by :attr:`github.GithubObject.GithubObject.raw_data` @@ -360,4 +361,4 @@ class Github(object): :param raw_data: dict :rtype: instance of class ``klass`` """ - return klass(self.__requester, raw_data, completed=True) + return klass(self.__requester, headers, raw_data, completed=True) diff --git a/github/Milestone.py b/github/Milestone.py index 9611d7b7..db38437f 100644 --- a/github/Milestone.py +++ b/github/Milestone.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # @@ -206,7 +207,7 @@ class Milestone(github.GithubObject.CompletableGithubObject): self._created_at = self._parseDatetime(attributes["created_at"]) if "creator" in attributes: # pragma no branch assert attributes["creator"] is None or isinstance(attributes["creator"], dict), attributes["creator"] - self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, attributes["creator"], completed=False) + self._creator = None if attributes["creator"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["creator"], completed=False) if "description" in attributes: # pragma no branch assert attributes["description"] is None or isinstance(attributes["description"], (str, unicode)), attributes["description"] self._description = attributes["description"] diff --git a/github/NamedUser.py b/github/NamedUser.py index b2a6dc48..ca29d38e 100644 --- a/github/NamedUser.py +++ b/github/NamedUser.py @@ -5,6 +5,7 @@ # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -271,7 +272,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Gist.Gist(self._requester, data, completed=True) + return github.Gist.Gist(self._requester, headers, data, completed=True) def get_events(self): """ @@ -394,7 +395,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): None, None ) - return github.Repository.Repository(self._requester, data, completed=True) + return github.Repository.Repository(self._requester, headers, data, completed=True) def get_repos(self, type=github.GithubObject.NotSet): """ @@ -556,7 +557,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject): self._owned_private_repos = attributes["owned_private_repos"] if "plan" in attributes: # pragma no branch assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"] - self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, attributes["plan"], completed=False) + self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False) if "private_gists" in attributes: # pragma no branch assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"] self._private_gists = attributes["private_gists"] diff --git a/github/Notification.py b/github/Notification.py index d0ecd7db..bb1c96b6 100644 --- a/github/Notification.py +++ b/github/Notification.py @@ -2,6 +2,7 @@ ############################ Copyrights and license ############################ # # +# Copyright 2013 AKFish # # Copyright 2013 Peter Golm # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # @@ -104,10 +105,10 @@ class Notification(github.GithubObject.CompletableGithubObject): self._id = attributes["id"] if "repository" in attributes: # pragma no branch assert attributes["repository"] is None or isinstance(attributes["repository"], dict), attributes["repository"] - self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, attributes["repository"], completed=False) + self._repository = None if attributes["repository"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repository"], completed=False) if "subject" in attributes: # pragma no branch assert attributes["subject"] is None or isinstance(attributes["subject"], dict), attributes["subject"] - self._subject = None if attributes["subject"] is None else github.NotificationSubject.NotificationSubject(self._requester, attributes["subject"], completed=False) + self._subject = None if attributes["subject"] is None else github.NotificationSubject.NotificationSubject(self._requester, self._headers, attributes["subject"], completed=False) if "reason" in attributes: # pragma no branch assert attributes["reason"] is None or isinstance(attributes["reason"], (str, unicode)), attributes["reason"] self._reason = attributes["reason"] diff --git a/github/NotificationSubject.py b/github/NotificationSubject.py index 169e1d89..7e1ce3ad 100644 --- a/github/NotificationSubject.py +++ b/github/NotificationSubject.py @@ -2,6 +2,7 @@ ############################ Copyrights and license ############################ # # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Organization.py b/github/Organization.py index efe9cef0..d252a054 100644 --- a/github/Organization.py +++ b/github/Organization.py @@ -5,6 +5,7 @@ # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # @@ -264,7 +265,7 @@ class Organization(github.GithubObject.CompletableGithubObject): url_parameters, None ) - return github.Repository.Repository(self._requester, data, completed=True) + return github.Repository.Repository(self._requester, headers, data, completed=True) def create_repo(self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, team_id=github.GithubObject.NotSet, auto_init=github.GithubObject.NotSet, gitignore_template=github.GithubObject.NotSet): """ @@ -318,7 +319,7 @@ class Organization(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Repository.Repository(self._requester, data, completed=True) + return github.Repository.Repository(self._requester, headers, data, completed=True) def create_team(self, name, repo_names=github.GithubObject.NotSet, permission=github.GithubObject.NotSet): """ @@ -344,7 +345,7 @@ class Organization(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Team.Team(self._requester, data, completed=True) + return github.Team.Team(self._requester, headers, data, completed=True) def edit(self, billing_email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, email=github.GithubObject.NotSet, location=github.GithubObject.NotSet, name=github.GithubObject.NotSet): """ @@ -471,7 +472,7 @@ class Organization(github.GithubObject.CompletableGithubObject): None, None ) - return github.Repository.Repository(self._requester, data, completed=True) + return github.Repository.Repository(self._requester, headers, data, completed=True) def get_repos(self, type=github.GithubObject.NotSet): """ @@ -503,7 +504,7 @@ class Organization(github.GithubObject.CompletableGithubObject): None, None ) - return github.Team.Team(self._requester, data, completed=True) + return github.Team.Team(self._requester, headers, data, completed=True) def get_teams(self): """ @@ -655,7 +656,7 @@ class Organization(github.GithubObject.CompletableGithubObject): self._owned_private_repos = attributes["owned_private_repos"] if "plan" in attributes: # pragma no branch assert attributes["plan"] is None or isinstance(attributes["plan"], dict), attributes["plan"] - self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, attributes["plan"], completed=False) + self._plan = None if attributes["plan"] is None else github.Plan.Plan(self._requester, self._headers, attributes["plan"], completed=False) if "private_gists" in attributes: # pragma no branch assert attributes["private_gists"] is None or isinstance(attributes["private_gists"], (int, long)), attributes["private_gists"] self._private_gists = attributes["private_gists"] diff --git a/github/PaginatedList.py b/github/PaginatedList.py index 90afc472..e450dfd8 100644 --- a/github/PaginatedList.py +++ b/github/PaginatedList.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Bill Mill # # Copyright 2013 Vincent Jacques # # Copyright 2013 davidbrai # @@ -152,7 +153,7 @@ class PaginatedList(PaginatedListBase): self.__nextParams = None content = [ - self.__contentClass(self.__requester, element, completed=False) + self.__contentClass(self.__requester, headers, element, completed=False) for element in data ] if self._reversed: @@ -179,6 +180,6 @@ class PaginatedList(PaginatedListBase): headers, data = self.__requester.requestJsonAndCheck("GET", self.__firstUrl, params, None) return [ - self.__contentClass(self.__requester, element, completed=False) + self.__contentClass(self.__requester, headers, element, completed=False) for element in data ] diff --git a/github/Permissions.py b/github/Permissions.py index 8b9f3b39..3a3b4206 100644 --- a/github/Permissions.py +++ b/github/Permissions.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/Plan.py b/github/Plan.py index 1daefc7c..99a3c3a6 100644 --- a/github/Plan.py +++ b/github/Plan.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # diff --git a/github/PullRequest.py b/github/PullRequest.py index 0adad292..8ea72e55 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -5,6 +5,7 @@ # Copyright 2012 Michael Stead # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # @@ -294,7 +295,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.PullRequestComment.PullRequestComment(self._requester, data, completed=True) + return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True) def create_issue_comment(self, body): """ @@ -312,7 +313,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.IssueComment.IssueComment(self._requester, data, completed=True) + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) def edit(self, title=github.GithubObject.NotSet, body=github.GithubObject.NotSet, state=github.GithubObject.NotSet): """ @@ -361,7 +362,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): None, None ) - return github.PullRequestComment.PullRequestComment(self._requester, data, completed=True) + return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -419,7 +420,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): None, None ) - return github.IssueComment.IssueComment(self._requester, data, completed=True) + return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) def get_issue_comments(self): """ @@ -462,7 +463,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.PullRequestMergeStatus.PullRequestMergeStatus(self._requester, data, completed=True) + return github.PullRequestMergeStatus.PullRequestMergeStatus(self._requester, headers, data, completed=True) def _initAttributes(self): self._additions = github.GithubObject.NotSet @@ -499,10 +500,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._additions = attributes["additions"] if "assignee" in attributes: # pragma no branch assert attributes["assignee"] is None or isinstance(attributes["assignee"], dict), attributes["assignee"] - self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, attributes["assignee"], completed=False) + self._assignee = None if attributes["assignee"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["assignee"], completed=False) if "base" in attributes: # pragma no branch assert attributes["base"] is None or isinstance(attributes["base"], dict), attributes["base"] - self._base = None if attributes["base"] is None else github.PullRequestPart.PullRequestPart(self._requester, attributes["base"], completed=False) + self._base = None if attributes["base"] is None else github.PullRequestPart.PullRequestPart(self._requester, self._headers, attributes["base"], completed=False) if "body" in attributes: # pragma no branch assert attributes["body"] is None or isinstance(attributes["body"], (str, unicode)), attributes["body"] self._body = attributes["body"] @@ -529,7 +530,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._diff_url = attributes["diff_url"] if "head" in attributes: # pragma no branch assert attributes["head"] is None or isinstance(attributes["head"], dict), attributes["head"] - self._head = None if attributes["head"] is None else github.PullRequestPart.PullRequestPart(self._requester, attributes["head"], completed=False) + self._head = None if attributes["head"] is None else github.PullRequestPart.PullRequestPart(self._requester, self._headers, attributes["head"], completed=False) if "html_url" in attributes: # pragma no branch assert attributes["html_url"] is None or isinstance(attributes["html_url"], (str, unicode)), attributes["html_url"] self._html_url = attributes["html_url"] @@ -550,7 +551,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._merged_at = self._parseDatetime(attributes["merged_at"]) if "merged_by" in attributes: # pragma no branch assert attributes["merged_by"] is None or isinstance(attributes["merged_by"], dict), attributes["merged_by"] - self._merged_by = None if attributes["merged_by"] is None else github.NamedUser.NamedUser(self._requester, attributes["merged_by"], completed=False) + self._merged_by = None if attributes["merged_by"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["merged_by"], completed=False) if "number" in attributes: # pragma no branch assert attributes["number"] is None or isinstance(attributes["number"], (int, long)), attributes["number"] self._number = attributes["number"] @@ -574,4 +575,4 @@ class PullRequest(github.GithubObject.CompletableGithubObject): self._url = attributes["url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py index c8f0ef6f..efc520cf 100644 --- a/github/PullRequestComment.py +++ b/github/PullRequestComment.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Michael Stead # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # @@ -211,4 +212,4 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject): self._html_url = attributes["html_url"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/PullRequestMergeStatus.py b/github/PullRequestMergeStatus.py index f9bae790..9c416dbd 100644 --- a/github/PullRequestMergeStatus.py +++ b/github/PullRequestMergeStatus.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # diff --git a/github/PullRequestPart.py b/github/PullRequestPart.py index 99778645..791452b0 100644 --- a/github/PullRequestPart.py +++ b/github/PullRequestPart.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -85,10 +86,10 @@ class PullRequestPart(github.GithubObject.NonCompletableGithubObject): self._ref = attributes["ref"] if "repo" in attributes: # pragma no branch assert attributes["repo"] is None or isinstance(attributes["repo"], dict), attributes["repo"] - self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, attributes["repo"], completed=False) + self._repo = None if attributes["repo"] is None else github.Repository.Repository(self._requester, self._headers, attributes["repo"], completed=False) if "sha" in attributes: # pragma no branch assert attributes["sha"] is None or isinstance(attributes["sha"], (str, unicode)), attributes["sha"] self._sha = attributes["sha"] if "user" in attributes: # pragma no branch assert attributes["user"] is None or isinstance(attributes["user"], dict), attributes["user"] - self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, attributes["user"], completed=False) + self._user = None if attributes["user"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["user"], completed=False) diff --git a/github/Repository.py b/github/Repository.py index 4361cf0a..ed5934d5 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -7,6 +7,7 @@ # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 Adrian Petrescu # +# Copyright 2013 AKFish # # Copyright 2013 Mark Roddy # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # @@ -336,7 +337,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Comparison.Comparison(self._requester, data, completed=True) + return github.Comparison.Comparison(self._requester, headers, data, completed=True) def create_download(self, name, size, description=github.GithubObject.NotSet, content_type=github.GithubObject.NotSet): """ @@ -365,7 +366,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Download.Download(self._requester, data, completed=True) + return github.Download.Download(self._requester, headers, data, completed=True) def create_git_blob(self, content, encoding): """ @@ -386,7 +387,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.GitBlob.GitBlob(self._requester, data, completed=True) + return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) def create_git_commit(self, message, tree, parents, author=github.GithubObject.NotSet, committer=github.GithubObject.NotSet): """ @@ -418,7 +419,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.GitCommit.GitCommit(self._requester, data, completed=True) + return github.GitCommit.GitCommit(self._requester, headers, data, completed=True) def create_git_ref(self, ref, sha): """ @@ -439,7 +440,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.GitRef.GitRef(self._requester, data, completed=True) + return github.GitRef.GitRef(self._requester, headers, data, completed=True) def create_git_tag(self, tag, message, object, type, tagger=github.GithubObject.NotSet): """ @@ -470,7 +471,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.GitTag.GitTag(self._requester, data, completed=True) + return github.GitTag.GitTag(self._requester, headers, data, completed=True) def create_git_tree(self, tree, base_tree=github.GithubObject.NotSet): """ @@ -492,7 +493,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.GitTree.GitTree(self._requester, data, completed=True) + return github.GitTree.GitTree(self._requester, headers, data, completed=True) def create_hook(self, name, config, events=github.GithubObject.NotSet, active=github.GithubObject.NotSet): """ @@ -521,7 +522,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Hook.Hook(self._requester, data, completed=True) + return github.Hook.Hook(self._requester, headers, data, completed=True) def create_issue(self, title, body=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, milestone=github.GithubObject.NotSet, labels=github.GithubObject.NotSet): """ @@ -555,7 +556,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Issue.Issue(self._requester, data, completed=True) + return github.Issue.Issue(self._requester, headers, data, completed=True) def create_key(self, title, key): """ @@ -576,7 +577,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.RepositoryKey.RepositoryKey(self._requester, data, completed=True, repoUrl=self._url) + return github.RepositoryKey.RepositoryKey(self._requester, headers, data, completed=True, repoUrl=self._url) def create_label(self, name, color): """ @@ -597,7 +598,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Label.Label(self._requester, data, completed=True) + return github.Label.Label(self._requester, headers, data, completed=True) def create_milestone(self, title, state=github.GithubObject.NotSet, description=github.GithubObject.NotSet, due_on=github.GithubObject.NotSet): """ @@ -627,7 +628,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.Milestone.Milestone(self._requester, data, completed=True) + return github.Milestone.Milestone(self._requester, headers, data, completed=True) def create_pull(self, *args, **kwds): """ @@ -665,7 +666,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, post_parameters ) - return github.PullRequest.PullRequest(self._requester, data, completed=True) + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) def delete(self): """ @@ -770,7 +771,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Branch.Branch(self._requester, data, completed=True) + return github.Branch.Branch(self._requester, headers, data, completed=True) def get_branches(self): """ @@ -809,7 +810,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.CommitComment.CommitComment(self._requester, data, completed=True) + return github.CommitComment.CommitComment(self._requester, headers, data, completed=True) def get_comments(self): """ @@ -836,7 +837,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Commit.Commit(self._requester, data, completed=True) + return github.Commit.Commit(self._requester, headers, data, completed=True) def get_commits(self, sha=github.GithubObject.NotSet, path=github.GithubObject.NotSet, since=github.GithubObject.NotSet, until=github.GithubObject.NotSet): """ @@ -894,7 +895,7 @@ class Repository(github.GithubObject.CompletableGithubObject): url_parameters, None ) - return github.ContentFile.ContentFile(self._requester, data, completed=True) + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) def get_dir_contents(self, path, ref=github.GithubObject.NotSet): """ @@ -925,7 +926,7 @@ class Repository(github.GithubObject.CompletableGithubObject): ) return [ - github.ContentFile.ContentFile(self._requester, attributes, completed=(attributes["type"] != "file")) # Lazy completion only makes sense for files. See discussion here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130 + github.ContentFile.ContentFile(self._requester, headers, attributes, completed=(attributes["type"] != "file")) # Lazy completion only makes sense for files. See discussion here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130 for attributes in data ] @@ -954,7 +955,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Download.Download(self._requester, data, completed=True) + return github.Download.Download(self._requester, headers, data, completed=True) def get_downloads(self): """ @@ -1005,7 +1006,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.GitBlob.GitBlob(self._requester, data, completed=True) + return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) def get_git_commit(self, sha): """ @@ -1020,7 +1021,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.GitCommit.GitCommit(self._requester, data, completed=True) + return github.GitCommit.GitCommit(self._requester, headers, data, completed=True) def get_git_ref(self, ref): """ @@ -1038,7 +1039,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.GitRef.GitRef(self._requester, data, completed=True) + return github.GitRef.GitRef(self._requester, headers, data, completed=True) def get_git_refs(self): """ @@ -1065,7 +1066,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.GitTag.GitTag(self._requester, data, completed=True) + return github.GitTag.GitTag(self._requester, headers, data, completed=True) def get_git_tree(self, sha, recursive=github.GithubObject.NotSet): """ @@ -1085,7 +1086,7 @@ class Repository(github.GithubObject.CompletableGithubObject): url_parameters, None ) - return github.GitTree.GitTree(self._requester, data, completed=True) + return github.GitTree.GitTree(self._requester, headers, data, completed=True) def get_hook(self, id): """ @@ -1100,7 +1101,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Hook.Hook(self._requester, data, completed=True) + return github.Hook.Hook(self._requester, headers, data, completed=True) def get_hooks(self): """ @@ -1127,7 +1128,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Issue.Issue(self._requester, data, completed=True) + return github.Issue.Issue(self._requester, headers, data, completed=True) def get_issues(self, milestone=github.GithubObject.NotSet, state=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, mentioned=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet): """ @@ -1218,7 +1219,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.IssueEvent.IssueEvent(self._requester, data, completed=True) + return github.IssueEvent.IssueEvent(self._requester, headers, data, completed=True) def get_issues_events(self): """ @@ -1245,7 +1246,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.RepositoryKey.RepositoryKey(self._requester, data, completed=True, repoUrl=self._url) + return github.RepositoryKey.RepositoryKey(self._requester, headers, data, completed=True, repoUrl=self._url) def get_keys(self): """ @@ -1253,7 +1254,7 @@ class Repository(github.GithubObject.CompletableGithubObject): :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.RepositoryKey.RepositoryKey` """ return github.PaginatedList.PaginatedList( - lambda requester, data, completed: github.RepositoryKey.RepositoryKey(requester, data, completed, repoUrl=self._url), + lambda requester, headers, data, completed: github.RepositoryKey.RepositoryKey(requester, headers, data, completed, repoUrl=self._url), self._requester, self.url + "/keys", None @@ -1272,7 +1273,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Label.Label(self._requester, data, completed=True) + return github.Label.Label(self._requester, headers, data, completed=True) def get_labels(self): """ @@ -1312,7 +1313,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.Milestone.Milestone(self._requester, data, completed=True) + return github.Milestone.Milestone(self._requester, headers, data, completed=True) def get_milestones(self, state=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet): """ @@ -1364,7 +1365,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None, None ) - return github.PullRequest.PullRequest(self._requester, data, completed=True) + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) def get_pulls(self, state=github.GithubObject.NotSet): """ @@ -1434,7 +1435,7 @@ class Repository(github.GithubObject.CompletableGithubObject): url_parameters, None ) - return github.ContentFile.ContentFile(self._requester, data, completed=True) + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) def get_stargazers(self): """ @@ -1542,7 +1543,7 @@ class Repository(github.GithubObject.CompletableGithubObject): None ) return [ - github.Issue.Issue(self._requester, github.Legacy.convertIssue(element), completed=False) + github.Issue.Issue(self._requester, headers, github.Legacy.convertIssue(element), completed=False) for element in data["issues"] ] @@ -1572,7 +1573,7 @@ class Repository(github.GithubObject.CompletableGithubObject): if data is None: return None else: - return github.Commit.Commit(self._requester, data, completed=True) + return github.Commit.Commit(self._requester, headers, data, completed=True) def remove_from_collaborators(self, collaborator): """ @@ -1719,16 +1720,16 @@ class Repository(github.GithubObject.CompletableGithubObject): self._open_issues = attributes["open_issues"] if "organization" in attributes: # pragma no branch assert attributes["organization"] is None or isinstance(attributes["organization"], dict), attributes["organization"] - self._organization = None if attributes["organization"] is None else github.Organization.Organization(self._requester, attributes["organization"], completed=False) + self._organization = None if attributes["organization"] is None else github.Organization.Organization(self._requester, self._headers, attributes["organization"], completed=False) if "owner" in attributes: # pragma no branch assert attributes["owner"] is None or isinstance(attributes["owner"], dict), attributes["owner"] - self._owner = None if attributes["owner"] is None else github.NamedUser.NamedUser(self._requester, attributes["owner"], completed=False) + self._owner = None if attributes["owner"] is None else github.NamedUser.NamedUser(self._requester, self._headers, attributes["owner"], completed=False) if "parent" in attributes: # pragma no branch assert attributes["parent"] is None or isinstance(attributes["parent"], dict), attributes["parent"] - self._parent = None if attributes["parent"] is None else Repository(self._requester, attributes["parent"], completed=False) + self._parent = None if attributes["parent"] is None else Repository(self._requester, self._headers, attributes["parent"], completed=False) if "permissions" in attributes: # pragma no branch assert attributes["permissions"] is None or isinstance(attributes["permissions"], dict), attributes["permissions"] - self._permissions = None if attributes["permissions"] is None else github.Permissions.Permissions(self._requester, attributes["permissions"], completed=False) + self._permissions = None if attributes["permissions"] is None else github.Permissions.Permissions(self._requester, self._headers, attributes["permissions"], completed=False) if "private" in attributes: # pragma no branch assert attributes["private"] is None or isinstance(attributes["private"], bool), attributes["private"] self._private = attributes["private"] @@ -1740,7 +1741,7 @@ class Repository(github.GithubObject.CompletableGithubObject): self._size = attributes["size"] if "source" in attributes: # pragma no branch assert attributes["source"] is None or isinstance(attributes["source"], dict), attributes["source"] - self._source = None if attributes["source"] is None else Repository(self._requester, attributes["source"], completed=False) + self._source = None if attributes["source"] is None else Repository(self._requester, self._headers, attributes["source"], completed=False) if "ssh_url" in attributes: # pragma no branch assert attributes["ssh_url"] is None or isinstance(attributes["ssh_url"], (str, unicode)), attributes["ssh_url"] self._ssh_url = attributes["ssh_url"] diff --git a/github/RepositoryKey.py b/github/RepositoryKey.py index 750541b2..074985d8 100644 --- a/github/RepositoryKey.py +++ b/github/RepositoryKey.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Srijan Choudhary # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # @@ -33,8 +34,8 @@ class RepositoryKey(github.GithubObject.CompletableGithubObject): This class represents RepositoryKeys. The reference can be found here http://developer.github.com/v3/repos/keys/ """ - def __init__(self, requester, attributes, completed, repoUrl): - github.GithubObject.CompletableGithubObject.__init__(self, requester, attributes, completed) + def __init__(self, requester, headers, attributes, completed, repoUrl): + github.GithubObject.CompletableGithubObject.__init__(self, requester, headers, attributes, completed) self.__repoUrl = repoUrl @property diff --git a/github/Requester.py b/github/Requester.py index 5677501f..c2e53b91 100644 --- a/github/Requester.py +++ b/github/Requester.py @@ -9,6 +9,7 @@ # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Ed Jackson # # Copyright 2013 Jonathan J Hunt # # Copyright 2013 Mark Roddy # @@ -63,7 +64,70 @@ class Requester: cls.__httpConnectionClass = httplib.HTTPConnection cls.__httpsConnectionClass = httplib.HTTPSConnection + ############################################################# + # For Debug + @classmethod + def setDebugFlag(cls, flag): + cls.DEBUG_FLAG = flag + + @classmethod + def setOnCheckMe(cls, onCheckMe): + cls.ON_CHECK_ME = onCheckMe + + DEBUG_FLAG = False + + DEBUG_FRAME_BUFFER_SIZE = 1024 + + DEBUG_HEADER_KEY = "DEBUG_FRAME" + + ON_CHECK_ME = None + + def NEW_DEBUG_FRAME(self, requestHeader): + ''' + Initialize a debug frame with requestHeader + Frame count is updated and will be attached to respond header + The structure of a frame: [requestHeader, statusCode, responseHeader, raw_data] + Some of them may be None + ''' + if not self.DEBUG_FLAG: + return + + new_frame = [requestHeader, None, None, None] + if self._frameCount < self.DEBUG_FRAME_BUFFER_SIZE - 1: + self._frameBuffer.append(new_frame) + else: + self._frameBuffer[0] = new_frame + + self._frameCount = len(self._frameBuffer) - 1 + + def DEBUG_ON_RESPONSE(self, statusCode, responseHeader, data): + ''' + Update current frame with response + Current frame index will be attached to responseHeader + ''' + if not self.DEBUG_FLAG: + return + + self._frameBuffer[self._frameCount][1:4] = [statusCode, responseHeader, data] + responseHeader[self.DEBUG_HEADER_KEY] = self._frameCount + + def check_me(self, obj): + if self.DEBUG_FLAG and self.ON_CHECK_ME is not None: + frame = None + if self.DEBUG_HEADER_KEY in obj._headers: + frame_index = obj._headers[self.DEBUG_HEADER_KEY] + frame = self._frameBuffer[frame_index] + self.ON_CHECK_ME(obj, frame) + + def _initializeDebugFeature(self): + self._frameCount = 0 + self._frameBuffer = [] + + ############################################################# + def __init__(self, login_or_token, password, base_url, timeout, client_id, client_secret, user_agent, per_page): + self._initializeDebugFeature() + if password is not None: login = login_or_token if atLeastPython3: @@ -111,6 +175,9 @@ class Requester: def __check(self, status, responseHeaders, output): output = self.__structuredFromJson(output) + # Log frame + self.DEBUG_ON_RESPONSE(status, responseHeaders, output) + if status >= 400: raise self.__createException(status, output) return responseHeaders, output @@ -177,6 +244,8 @@ class Requester: if input is not None: requestHeaders["Content-Type"], encoded_input = encode(input) + self.NEW_DEBUG_FRAME(requestHeaders) + status, responseHeaders, output = self.__requestRaw(verb, url, requestHeaders, encoded_input) if "x-ratelimit-remaining" in responseHeaders and "x-ratelimit-limit" in responseHeaders: diff --git a/github/Tag.py b/github/Tag.py index 5a42f637..890c1a02 100644 --- a/github/Tag.py +++ b/github/Tag.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # @@ -71,7 +72,7 @@ class Tag(github.GithubObject.NonCompletableGithubObject): def _useAttributes(self, attributes): if "commit" in attributes: # pragma no branch assert attributes["commit"] is None or isinstance(attributes["commit"], dict), attributes["commit"] - self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, attributes["commit"], completed=False) + self._commit = None if attributes["commit"] is None else github.Commit.Commit(self._requester, self._headers, attributes["commit"], completed=False) if "name" in attributes: # pragma no branch assert attributes["name"] is None or isinstance(attributes["name"], (str, unicode)), attributes["name"] self._name = attributes["name"] diff --git a/github/Team.py b/github/Team.py index b6d681d6..804ed3ab 100644 --- a/github/Team.py +++ b/github/Team.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # diff --git a/github/UserKey.py b/github/UserKey.py index 222cd1a5..44cc5808 100644 --- a/github/UserKey.py +++ b/github/UserKey.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # # diff --git a/github/tests/Framework.py b/github/tests/Framework.py index 706bdbdd..24e814b4 100644 --- a/github/tests/Framework.py +++ b/github/tests/Framework.py @@ -4,6 +4,7 @@ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # +# Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # # # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # @@ -244,8 +245,24 @@ class BasicTestCase(unittest.TestCase): class TestCase(BasicTestCase): + def doCheckFrame(self, obj, frame): + if obj._headers == {} and frame is None: + return + if obj._headers is None and frame == {}: + return + self.assertEqual(obj._headers, frame[2]) + + def getFrameChecker(self): + return lambda requester, obj, frame: self.doCheckFrame(obj, frame) + def setUp(self): BasicTestCase.setUp(self) + + # Set up frame debugging + github.GithubObject.GithubObject.setCheckAfterInitFlag(True) + github.Requester.Requester.setDebugFlag(True) + github.Requester.Requester.setOnCheckMe(self.getFrameChecker()) + self.g = github.Github(self.login, self.password)