From ed32e78da1303962afaf8fa0d616a1828fdaa80b Mon Sep 17 00:00:00 2001 From: AKFish Date: Wed, 21 Aug 2013 15:26:05 +0800 Subject: [PATCH] Update Commit.py and GitCommit.py --- github/Branch.py | 2 +- github/Commit.py | 7 ++----- github/Comparison.py | 4 ++-- github/GitCommit.py | 5 +---- github/PaginatedList.py | 19 +++++++------------ github/Repository.py | 8 ++++---- github/Tag.py | 2 +- 7 files changed, 18 insertions(+), 29 deletions(-) diff --git a/github/Branch.py b/github/Branch.py index 11f074d5..5004f2f6 100644 --- a/github/Branch.py +++ b/github/Branch.py @@ -55,7 +55,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 ada886d1..91219da1 100644 --- a/github/Commit.py +++ b/github/Commit.py @@ -39,9 +39,6 @@ class Commit(github.GithubObject.CompletableGithubObject): """ This class represents Commits. The reference can be found here http://developer.github.com/v3/git/commits/ """ - def __init__(self, requester, attributes, completed): - # Adapte for __init__ change, remove later - github.GithubObject.CompletableGithubObject.__init__(self, requester, {}, attributes, completed) @property def author(self): @@ -207,7 +204,7 @@ class Commit(github.GithubObject.CompletableGithubObject): self._author = None if attributes["author"] is None else github.NamedUser.NamedUser(self._requester, 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) @@ -220,7 +217,7 @@ class Commit(github.GithubObject.CompletableGithubObject): 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 diff --git a/github/Comparison.py b/github/Comparison.py index a131d1b6..3182b43d 100644 --- a/github/Comparison.py +++ b/github/Comparison.py @@ -153,14 +153,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 diff --git a/github/GitCommit.py b/github/GitCommit.py index 488c82d0..e9272bdc 100644 --- a/github/GitCommit.py +++ b/github/GitCommit.py @@ -33,9 +33,6 @@ class GitCommit(github.GithubObject.CompletableGithubObject): """ This class represents GitCommits as returned for example by http://developer.github.com/v3/todo """ - def __init__(self, requester, attributes, completed): - # Adapte for __init__ change, remove later - github.GithubObject.CompletableGithubObject.__init__(self, requester, {}, attributes, completed) @property def author(self): @@ -119,7 +116,7 @@ class GitCommit(github.GithubObject.CompletableGithubObject): 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 diff --git a/github/PaginatedList.py b/github/PaginatedList.py index 1911f098..1ab477e1 100644 --- a/github/PaginatedList.py +++ b/github/PaginatedList.py @@ -118,21 +118,16 @@ class PaginatedList(PaginatedListBase): ''' Adapte for diffrent __init__ signature in refactoring, remove when done ''' - try: - try: # Try use old __init__ signature - return [ - self.__contentClass(self.__requester, element, completed=False) - for element in data] - except TypeError: # must be new - return [ - self.__contentClass(self.__requester, headers, element, completed=False) - for element in data] - except: - print "WTF???????????" - print self.__contentClass + + try: # Try use old __init__ signature return [ self.__contentClass(self.__requester, element, completed=False) for element in data] + except TypeError: # must be new + return [ + self.__contentClass(self.__requester, headers, element, completed=False) + for element in data] + diff --git a/github/Repository.py b/github/Repository.py index e8077b14..67c316d2 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -420,7 +420,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): """ @@ -838,7 +838,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): """ @@ -1014,7 +1014,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): """ @@ -1566,7 +1566,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): """ diff --git a/github/Tag.py b/github/Tag.py index 5a42f637..9300b607 100644 --- a/github/Tag.py +++ b/github/Tag.py @@ -71,7 +71,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"]