Manual implementation of some status checks

This commit is contained in:
Vincent Jacques
2012-05-30 18:40:22 +02:00
parent b42e1284ec
commit b2cdba9cb5
7 changed files with 42 additions and 4 deletions
+3 -1
View File
@@ -148,7 +148,7 @@ class AuthenticatedUser( object ):
return self.__url
def add_to_emails( self, *emails ):
assert len( emails ) == 0 or isinstance( emails[ 0 ], ( str, unicode ) ), emails
assert all( isinstance( email, ( str, unicode ) ) for email in emails ), emails
post_parameters = emails
status, headers, data = self.__requester.request(
"POST",
@@ -238,6 +238,8 @@ class AuthenticatedUser( object ):
None,
post_parameters
)
if self.__requester.isFailureStatus( status ):
raise GithubException( status, data )
return UserKey.UserKey( self.__requester, data, completion = NoCompletion )
def create_repo( self, name, description = DefaultValueForOptionalParameters, homepage = DefaultValueForOptionalParameters, private = DefaultValueForOptionalParameters, has_issues = DefaultValueForOptionalParameters, has_wiki = DefaultValueForOptionalParameters, has_downloads = DefaultValueForOptionalParameters ):
+6
View File
@@ -6,3 +6,9 @@ DefaultValueForOptionalParameters = DefaultValueForOptionalParametersType()
LazyCompletion = 0
ImmediateCompletion = 1
NoCompletion = 2
class GithubException( Exception ):
def __init__( self, status, data ):
Exception.__init__( self )
self.status = status
self.data = data
+3 -3
View File
@@ -3,9 +3,6 @@ import json
import base64
import urllib
class UnknownGithubObject( Exception ):
pass
class Requester:
def __init__( self, login_or_token, password ):
if password is not None:
@@ -61,3 +58,6 @@ class Requester:
def parentUrl( self, url ):
return "/".join( url.split( "/" )[ : -1 ] )
def isFailureStatus( self, status ):
return status >= 400
+1
View File
@@ -1 +1,2 @@
from Github import Github
from GithubObject import GithubException