Improve management of lazy completion

This commit is contained in:
Vincent Jacques
2012-05-12 15:28:07 +02:00
parent 350c7a3726
commit a72d8b1358
42 changed files with 198 additions and 191 deletions
+5 -4
View File
@@ -4,6 +4,7 @@ import NamedUser
import Organization
import Gist
import PaginatedList
from GithubObject import LazyCompletion, ImmediateCompletion
class Github:
def __init__( self, login, password ):
@@ -15,27 +16,27 @@ class Github:
"url": "https://api.github.com/user", # @todo Erf, this url is replaced by /users/login when __complete is called...
# "login": self.__login # @todo ?
}
return AuthenticatedUser.AuthenticatedUser( self.__requester, attributes, lazy = True )
return AuthenticatedUser.AuthenticatedUser( self.__requester, attributes, completion = LazyCompletion )
else:
attributes = {
"url": "https://api.github.com/users/" + login,
"login": login,
}
return NamedUser.NamedUser( self.__requester, attributes, lazy = False )
return NamedUser.NamedUser( self.__requester, attributes, completion = ImmediateCompletion )
def get_organization( self, login ):
attributes = {
"url": "https://api.github.com/orgs/" + login,
"login": login,
}
return Organization.Organization( self.__requester, attributes, lazy = False )
return Organization.Organization( self.__requester, attributes, completion = ImmediateCompletion )
def get_gist( self, id ):
attributes = {
"url": "https://api.github.com/gists/" + str( id ),
"id": id,
}
return Gist.Gist( self.__requester, attributes, lazy = False )
return Gist.Gist( self.__requester, attributes, completion = ImmediateCompletion )
def get_gists( self ):
status, headers, data = self.__requester.request( "GET", "https://api.github.com/gists/public", None, None )