<s> """<STR_LIT>""" <EOL> import base64 <EOL> import sys <EOL> import urllib <EOL> from bottle import request , HTTPResponse , redirect <EOL> from oauthlib . common import to_unicode , bytes_type <EOL> def redirect_with_query ( redirect_uri , params ) : <EOL> """<STR_LIT>""" <EOL> return redirect ( redirect_uri + '<STR_LIT:?>' + urllib . urlencode ( params ) ) <EOL> """<STR_LIT>""" <EOL> def extract_params ( extract_body ) : <EOL> """<STR_LIT>""" <EOL> uri = request . url <EOL> http_method = request . method <EOL> if extract_body : <EOL> body = dict ( request . forms ) <EOL> else : <EOL> body = None <EOL> headers = dict ( request . headers ) <EOL> if '<STR_LIT>' in headers : <EOL> del headers [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in headers : <EOL> del headers [ '<STR_LIT>' ] <EOL> return uri , http_method , body , headers <EOL> def to_bytes ( text , encoding = '<STR_LIT:utf-8>' ) : <EOL> """<STR_LIT>""" <EOL> if not text : <EOL> return text <EOL> if not isinstance ( text , bytes_type ) : <EOL> text = text . encode ( encoding ) <EOL> return text <EOL> def decode_base64 ( text , encoding = '<STR_LIT:utf-8>' ) : <EOL> """<STR_LIT>""" <EOL> text = to_bytes ( text , encoding ) <EOL> return to_unicode ( base64 . b64decode ( text ) , encoding ) <EOL> def create_response ( headers , body , status ) : <EOL> """<STR_LIT>""" <EOL> return HTTPResponse ( body or '<STR_LIT>' , status = status , headers = headers ) <EOL> """<STR_LIT>""" <EOL> class cached_property ( property ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , func , name = None , doc = None ) : <EOL> self . __name__ = name or func . __name__ <EOL> self . __module__ = func . __module__ <EOL> self . __doc__ = doc or func . __doc__ <EOL> self . func = func <EOL> def __set__ ( self , obj , value ) : <EOL> obj . __dict__ [ self . __name__ ] = value <EOL> def __get__ ( self , obj , type = None ) : <EOL> if obj is None : <EOL> return self <EOL> value = obj . __dict__ . get ( self . __name__ , None ) <EOL> if value is None : <EOL> value = self . func ( obj ) <EOL> obj . __dict__ [ self . __name__ ] = value <EOL> return value <EOL> def import_string ( import_name , silent = False ) : <EOL> """<STR_LIT>""" <EOL> import_name = str ( import_name ) . replace ( '<STR_LIT::>' , '<STR_LIT:.>' ) <EOL> try : <EOL> __import__ ( import_name ) <EOL> except ImportError : <EOL> if '<STR_LIT:.>' not in import_name : <EOL> raise <EOL> else : <EOL> return sys . modules [ import_name ] <EOL> module_name , obj_name = import_name . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> try : <EOL> module = __import__ ( module_name , None , None , [ obj_name ] ) <EOL> except ImportError : <EOL> module = import_string ( module_name ) <EOL> try : <EOL> return getattr ( module , obj_name ) <EOL> except AttributeError as e : <EOL> raise ImportError ( e ) </s>
