<s> """<STR_LIT>""" <EOL> from werkzeug . utils import cached_property <EOL> from werkzeug . wrappers import Request as BaseRequest <EOL> from werkzeug . wrappers import Response as BaseResponse <EOL> from werkzeug . datastructures import ImmutableMultiDict <EOL> from . helpers import local , StorageDict , to_unicode <EOL> from . serializers import from_json , to_json <EOL> __all__ = ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ) <EOL> class Request ( BaseRequest ) : <EOL> """<STR_LIT>""" <EOL> url_rule = None <EOL> endpoint = None <EOL> kwargs = None <EOL> parameter_storage_class = ImmutableMultiDict <EOL> max_content_length = <NUM_LIT:0> <EOL> max_form_memory_size = <NUM_LIT:0> <EOL> @ property <EOL> def is_get ( self ) : <EOL> return self . method == '<STR_LIT:GET>' <EOL> @ property <EOL> def is_post ( self ) : <EOL> return self . method == '<STR_LIT:POST>' <EOL> @ property <EOL> def is_put ( self ) : <EOL> return self . method == '<STR_LIT>' <EOL> @ property <EOL> def is_delete ( self ) : <EOL> return self . method == '<STR_LIT>' <EOL> @ cached_property <EOL> def json ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . mimetype == '<STR_LIT:application/json>' : <EOL> return from_json ( self . data ) <EOL> class Response ( BaseResponse ) : <EOL> """<STR_LIT>""" <EOL> default_mimetype = '<STR_LIT>' <EOL> class Settings ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , custom , default ) : <EOL> if isinstance ( custom , dict ) : <EOL> custom = StorageDict ( custom ) <EOL> if isinstance ( default , dict ) : <EOL> default = StorageDict ( default ) <EOL> self . __dict__ [ '<STR_LIT>' ] = custom <EOL> self . __dict__ [ '<STR_LIT:default>' ] = default <EOL> def __contains__ ( self , key ) : <EOL> return hasattr ( self . __dict__ [ '<STR_LIT>' ] , key ) <EOL> def __getattr__ ( self , key ) : <EOL> dcustom = self . __dict__ [ '<STR_LIT>' ] <EOL> ddefault = self . __dict__ [ '<STR_LIT:default>' ] <EOL> if hasattr ( dcustom , key ) : <EOL> return getattr ( dcustom , key ) <EOL> if hasattr ( ddefault , key ) : <EOL> return getattr ( ddefault , key ) <EOL> if hasattr ( ddefault , key . lower ( ) ) : <EOL> return getattr ( ddefault , key . lower ( ) ) <EOL> raise AttributeError ( key ) <EOL> def __setattr__ ( self , key , value ) : <EOL> setattr ( self . __dict__ [ '<STR_LIT>' ] , key , value ) <EOL> def __delattr__ ( self , key ) : <EOL> delattr ( self . __dict__ [ '<STR_LIT>' ] , key ) <EOL> __getitem__ = __getattr__ <EOL> __setitem__ = __setattr__ <EOL> __delitem__ = __delattr__ <EOL> def get ( self , key , default = None ) : <EOL> dcustom = self . __dict__ [ '<STR_LIT>' ] <EOL> ddefault = self . __dict__ [ '<STR_LIT:default>' ] <EOL> if hasattr ( dcustom , key ) : <EOL> return getattr ( dcustom , key ) <EOL> if hasattr ( ddefault , key ) : <EOL> return getattr ( ddefault , key ) <EOL> if hasattr ( ddefault , key . lower ( ) ) : <EOL> return getattr ( ddefault , key . lower ( ) ) <EOL> return default <EOL> def setdefault ( self , key , value ) : <EOL> dcustom = self . __dict__ [ '<STR_LIT>' ] <EOL> if hasattr ( dcustom , key ) : <EOL> return getattr ( dcustom , key ) <EOL> setattr ( dcustom , key , value ) <EOL> return value <EOL> def update ( self , dict_ ) : <EOL> dcustom = self . __dict__ [ '<STR_LIT>' ] <EOL> for key , value in dict_ . items ( ) : <EOL> setattr ( dcustom , key , value ) <EOL> def make_response ( resp = '<STR_LIT>' , status = None , headers = None , <EOL> response_class = Response , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if resp is None : <EOL> resp = '<STR_LIT>' <EOL> if isinstance ( resp , dict ) : <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT:application/json>' <EOL> resp = to_json ( resp , indent = None ) <EOL> if not isinstance ( resp , BaseResponse ) : <EOL> if isinstance ( resp , basestring ) : <EOL> resp = response_class ( resp , status = status , headers = headers , <EOL> ** kwargs ) <EOL> headers = status = None <EOL> elif not callable ( resp ) : <EOL> resp = to_unicode ( resp ) <EOL> resp = response_class ( resp , status = status , headers = headers , <EOL> ** kwargs ) <EOL> headers = status = None <EOL> else : <EOL> resp = response_class . force_type ( resp , local . request . environ ) <EOL> if status is not None : <EOL> if isinstance ( status , basestring ) : <EOL> resp . status = status <EOL> else : <EOL> resp . status_code = status <EOL> if headers : <EOL> resp . headers . extend ( headers ) <EOL> return resp </s>
