Files
PyGithub/github/Github.py
T
Vincent Jacques 04cde900a0 On the way to code generation instead of meta-description
(lots of useless eratic history squashed together in one commit)
2012-05-03 21:51:19 +01:00

41 lines
1.5 KiB
Python

from Requester import Requester
import GithubObjects.AuthenticatedUser
import GithubObjects.NamedUser
import GithubObjects.Organization
import GithubObjects.Gist
class Github:
def __init__( self, login, password, debugFile = None ):
self.__requester = Requester( login, password )
self.__debugFile = debugFile
def _dataRequest( self, verb, url, parameters, data ):
return self.__requester.dataRequest( verb, url, parameters, data )
def _statusRequest( self, verb, url, parameters, data ):
return self.__requester.statusRequest( verb, url, parameters, data )
def get_user( self, login = None ):
if login is None:
attributes = { "url": "https://api.github.com/user" }
return GithubObjects.AuthenticatedUser.AuthenticatedUser( self, attributes, lazy = True )
else:
return GithubObjects.NamedUser.NamedUser( self, { "login": login }, lazy = False )
def get_organization( self, login ):
return GithubObjects.Organization.Organization( self, { "login": login }, lazy = False )
def get_gist( self, id ):
return GithubObjects.Gist.Gist( self, { "id": id }, lazy = False )
def get_gists( self ):
return [
GithubObjects.Gist.Gist( self, attributes, lazy = True )
for attributes
in self._dataRequest( "GET", "/gists/public", None, None )
]
def _printDebug( self, *args ):
if self.__debugFile is not None:
self.__debugFile.write( " ".join( str( arg ) for arg in args ) + "\n" )