<s> import base64 <EOL> from refreshbooks import exceptions <EOL> try : <EOL> from refreshbooks . optional import oauth as os <EOL> OAuthAuthorization = os . OAuthAuthorization <EOL> except ImportError : <EOL> def OAuthAuthorization ( consumer , token , sig_method = None ) : <EOL> raise NotImplementedError ( '<STR_LIT>' ) <EOL> try : <EOL> from refreshbooks . transports import use_requests as transport <EOL> except ImportError : <EOL> try : <EOL> from refreshbooks . transports import use_httplib2 as transport <EOL> except ImportError : <EOL> import warnings <EOL> warnings . warn ( <EOL> "<STR_LIT>" <EOL> ) <EOL> from refreshbooks . transports import use_urllib2 as transport <EOL> class TokenAuthorization ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , token ) : <EOL> try : <EOL> token = token . encode ( '<STR_LIT>' ) <EOL> except NameError : <EOL> pass <EOL> base64_user_pass = base64 . b64encode ( token + b'<STR_LIT::>' ) . decode ( '<STR_LIT>' ) <EOL> self . headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' % ( base64_user_pass , ) <EOL> } <EOL> def __call__ ( self ) : <EOL> return self . headers <EOL> class UserAgentHeaders ( object ) : <EOL> def __init__ ( self , base_headers_factory , user_agent ) : <EOL> self . base_headers_factory = base_headers_factory <EOL> self . user_agent = user_agent <EOL> def __call__ ( self ) : <EOL> headers = self . base_headers_factory ( ) <EOL> headers [ '<STR_LIT>' ] = self . user_agent <EOL> return headers <EOL> class KeepAliveHeaders ( object ) : <EOL> def __init__ ( self , base_headers_factory ) : <EOL> self . base_headers_factory = base_headers_factory <EOL> def __call__ ( self ) : <EOL> headers = self . base_headers_factory ( ) <EOL> headers [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return headers <EOL> HttpTransport = transport . Transport <EOL> TransportException = exceptions . TransportException </s>
