Permalink
Browse files

Do all paginated calls inside PaginatedList

This was already the case for Legacy.PaginatedList.

Doing it in PaginatedList.PaginatedList reduces the amount of
repeated code and will allow a generic solution for issue #77
  • Loading branch information...
1 parent 25a7696 commit ef403a15947f3fd5176fa97e6a2f2b0e7dfa6913 @jacquev6 jacquev6 committed Sep 11, 2012
View
@@ -332,17 +332,11 @@ def get_authorization( self, id ):
return Authorization.Authorization( self._requester, data, completed = True )
def get_authorizations( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/authorizations",
- None,
- None
- )
return PaginatedList.PaginatedList(
Authorization.Authorization,
self._requester,
- headers,
- data
+ "/authorizations",
+ None
)
def get_emails( self ):
@@ -355,73 +349,43 @@ def get_emails( self ):
return data
def get_events( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/events",
- None,
- None
- )
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
- headers,
- data
+ "/events",
+ None
)
def get_followers( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/followers",
- None,
- None
- )
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
- headers,
- data
+ "/user/followers",
+ None
)
def get_following( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/following",
- None,
- None
- )
return PaginatedList.PaginatedList(
NamedUser.NamedUser,
self._requester,
- headers,
- data
+ "/user/following",
+ None
)
def get_gists( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/gists",
- None,
- None
- )
return PaginatedList.PaginatedList(
Gist.Gist,
self._requester,
- headers,
- data
+ "/gists",
+ None
)
def get_issues( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/issues",
- None,
- None
- )
return PaginatedList.PaginatedList(
Issue.Issue,
self._requester,
- headers,
- data
+ "/issues",
+ None
)
def get_key( self, id ):
@@ -435,46 +399,28 @@ def get_key( self, id ):
return UserKey.UserKey( self._requester, data, completed = True )
def get_keys( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/keys",
- None,
- None
- )
return PaginatedList.PaginatedList(
UserKey.UserKey,
self._requester,
- headers,
- data
+ "/user/keys",
+ None
)
def get_organization_events( self, org ):
assert isinstance( org, Organization.Organization ), org
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/users/" + self.login + "/events/orgs/" + org.login,
- None,
- None
- )
return PaginatedList.PaginatedList(
Event.Event,
self._requester,
- headers,
- data
+ "/users/" + self.login + "/events/orgs/" + org.login,
+ None
)
def get_orgs( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/orgs",
- None,
- None
- )
return PaginatedList.PaginatedList(
Organization.Organization,
self._requester,
- headers,
- data
+ "/user/orgs",
+ None
)
def get_repo( self, name ):
@@ -498,73 +444,43 @@ def get_repos( self, type = GithubObject.NotSet, sort = GithubObject.NotSet, dir
url_parameters[ "sort" ] = sort
if direction is not GithubObject.NotSet:
url_parameters[ "direction" ] = direction
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/repos",
- url_parameters,
- None
- )
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
- headers,
- data
+ "/user/repos",
+ url_parameters
)
def get_starred( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/starred",
- None,
- None
- )
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
- headers,
- data
+ "/user/starred",
+ None
)
def get_starred_gists( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/gists/starred",
- None,
- None
- )
return PaginatedList.PaginatedList(
Gist.Gist,
self._requester,
- headers,
- data
+ "/gists/starred",
+ None
)
def get_subscriptions( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/subscriptions",
- None,
- None
- )
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
- headers,
- data
+ "/user/subscriptions",
+ None
)
def get_watched( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- "/user/watched",
- None,
- None
- )
return PaginatedList.PaginatedList(
Repository.Repository,
self._requester,
- headers,
- data
+ "/user/watched",
+ None
)
def has_in_following( self, following ):
View
@@ -105,31 +105,19 @@ def create_status( self, state, target_url = GithubObject.NotSet, description =
return CommitStatus.CommitStatus( self._requester, data, completed = True )
def get_comments( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- self.url + "/comments",
- None,
- None
- )
return PaginatedList.PaginatedList(
CommitComment.CommitComment,
self._requester,
- headers,
- data
+ self.url + "/comments",
+ None
)
def get_statuses( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- self._parentUrl( self._parentUrl( self.url ) ) + "/statuses/" + self.sha,
- None,
- None
- )
return PaginatedList.PaginatedList(
CommitStatus.CommitStatus,
self._requester,
- headers,
- data
+ self._parentUrl( self._parentUrl( self.url ) ) + "/statuses/" + self.sha,
+ None
)
@property
View
@@ -154,17 +154,11 @@ def get_comment( self, id ):
return GistComment.GistComment( self._requester, data, completed = True )
def get_comments( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- self.url + "/comments",
- None,
- None
- )
return PaginatedList.PaginatedList(
GistComment.GistComment,
self._requester,
- headers,
- data
+ self.url + "/comments",
+ None
)
def is_starred( self ):
View
@@ -69,12 +69,11 @@ def get_gist( self, id ):
return Gist.Gist( self.__requester, data, completed = True )
def get_gists( self ):
- headers, data = self.__requester.requestAndCheck( "GET", "/gists/public", None, None )
return PaginatedList.PaginatedList(
Gist.Gist,
self.__requester,
- headers,
- data
+ "/gists/public",
+ None
)
def legacy_search_repos( self, keyword, language = GithubObject.NotSet ):
View
@@ -183,45 +183,27 @@ def get_comment( self, id ):
return IssueComment.IssueComment( self._requester, data, completed = True )
def get_comments( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- self.url + "/comments",
- None,
- None
- )
return PaginatedList.PaginatedList(
IssueComment.IssueComment,
self._requester,
- headers,
- data
+ self.url + "/comments",
+ None
)
def get_events( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- self.url + "/events",
- None,
- None
- )
return PaginatedList.PaginatedList(
IssueEvent.IssueEvent,
self._requester,
- headers,
- data
+ self.url + "/events",
+ None
)
def get_labels( self ):
- headers, data = self._requester.requestAndCheck(
- "GET",
- self.url + "/labels",
- None,
- None
- )
return PaginatedList.PaginatedList(
Label.Label,
self._requester,
- headers,
- data
+ self.url + "/labels",
+ None
)
def remove_from_labels( self, label ):
View
@@ -15,7 +15,7 @@
class PaginatedList( PaginatedListBase ):
def __init__( self, url, args, requester, key, convert, contentClass ):
- PaginatedListBase.__init__( self, list() )
+ PaginatedListBase.__init__( self )
self.__url = url
self.__args = args
self.__requester = requester
@@ -24,7 +24,6 @@ def __init__( self, url, args, requester, key, convert, contentClass ):
self.__contentClass = contentClass
self.__nextPage = 1
self.__continue = True
- self.__elements = list()
def _couldGrow( self ):
return self.__continue
Oops, something went wrong.

0 comments on commit ef403a1

Please sign in to comment.