11# Copyright 2012-2016 Jonathan Paugh and contributors
22# See COPYING for license details
3- from agithub .base import *
3+ import base64
4+
5+ from agithub .base import API , ConnectionProperties , Client
6+
47
58class GitHub (API ):
6- '''
9+ """
710 The agnostic GitHub API. It doesn't know, and you don't care.
811 >>> from agithub import GitHub
912 >>> g = GitHub('user', 'pass')
@@ -28,29 +31,35 @@ class GitHub(API):
2831 NOTE: It is up to you to spell things correctly. A GitHub object
2932 doesn't even try to validate the url you feed it. On the other hand,
3033 it automatically supports the full API--so why should you care?
31- '''
32- def __init__ (self , username = None , password = None , token = None , * args , ** kwargs ):
33- extraHeaders = {'accept' : 'application/vnd.github.v3+json' }
34+ """
35+ def __init__ (self , username = None , password = None , token = None ,
36+ * args , ** kwargs ):
37+ extraHeaders = {'accept' : 'application/vnd.github.v3+json' }
3438 auth = self .generateAuthHeader (username , password , token )
35- if auth != None :
39+ if auth is not None :
3640 extraHeaders ['authorization' ] = auth
3741 props = ConnectionProperties (
38- api_url = kwargs .pop ('api_url' , 'api.github.com' ),
39- secure_http = True ,
40- extra_headers = extraHeaders
41- )
42+ api_url = kwargs .pop ('api_url' , 'api.github.com' ),
43+ secure_http = True ,
44+ extra_headers = extraHeaders
45+ )
4246
4347 self .setClient (Client (* args , ** kwargs ))
4448 self .setConnectionProperties (props )
4549
4650 def generateAuthHeader (self , username = None , password = None , token = None ):
4751 if token is not None :
4852 if password is not None :
49- raise TypeError ("You cannot use both password and oauth token authenication" )
53+ raise TypeError (
54+ "You cannot use both password and oauth token "
55+ "authenication"
56+ )
5057 return 'Token %s' % token
5158 elif username is not None :
5259 if password is None :
53- raise TypeError ("You need a password to authenticate as " + username )
60+ raise TypeError (
61+ "You need a password to authenticate as " + username
62+ )
5463 self .username = username
5564 return self .hash_pass (password )
5665
0 commit comments