From 2f31828502c95fef62970db7d4ca49fa8b4b8e0d Mon Sep 17 00:00:00 2001 From: AKFish Date: Wed, 21 Aug 2013 15:04:34 +0800 Subject: [PATCH] Update RepositoryKey.py --- github/PaginatedList.py | 18 +++++++++++++----- github/Repository.py | 6 +++--- github/RepositoryKey.py | 5 ++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/github/PaginatedList.py b/github/PaginatedList.py index cad474de..1911f098 100644 --- a/github/PaginatedList.py +++ b/github/PaginatedList.py @@ -118,14 +118,22 @@ class PaginatedList(PaginatedListBase): ''' Adapte for diffrent __init__ signature in refactoring, remove when done ''' - try: # Try use old __init__ signature + 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 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] + def _fetchNextPage(self): diff --git a/github/Repository.py b/github/Repository.py index 50822782..e8077b14 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -578,7 +578,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): """ @@ -1239,7 +1239,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): """ @@ -1247,7 +1247,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 diff --git a/github/RepositoryKey.py b/github/RepositoryKey.py index 788ac6e3..9a7c7b28 100644 --- a/github/RepositoryKey.py +++ b/github/RepositoryKey.py @@ -33,9 +33,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): - ##############NOTE: this one should not be removed but modified - 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