<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import copy <EOL> from events import Events <EOL> from flask import Flask <EOL> from werkzeug . routing import BaseConverter <EOL> from werkzeug . serving import WSGIRequestHandler <EOL> import eve <EOL> from eve . defaults import build_defaults <EOL> from eve . endpoints import collections_endpoint , item_endpoint , home_endpoint , error_endpoint , media_endpoint , schema_collection_endpoint , schema_item_endpoint <EOL> from eve . exceptions import ConfigException , SchemaException <EOL> from eve . io . mongo import Mongo , Validator , GridFSMediaStorage , create_index <EOL> from eve . logging import RequestFilter <EOL> from eve . utils import api_prefix , extract_key_values <EOL> class EveWSGIRequestHandler ( WSGIRequestHandler ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def server_version ( self ) : <EOL> return '<STR_LIT>' % eve . __version__ + super ( EveWSGIRequestHandler , <EOL> self ) . server_version <EOL> class RegexConverter ( BaseConverter ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , url_map , * items ) : <EOL> super ( RegexConverter , self ) . __init__ ( url_map ) <EOL> self . regex = items [ <NUM_LIT:0> ] <EOL> class Eve ( Flask , Events ) : <EOL> """<STR_LIT>""" <EOL> supported_resource_methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' , '<STR_LIT>' ] <EOL> supported_item_methods = [ '<STR_LIT:GET>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , import_name = __package__ , settings = '<STR_LIT>' , <EOL> validator = Validator , data = Mongo , auth = None , redis = None , <EOL> url_converters = None , json_encoder = None , <EOL> media = GridFSMediaStorage , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> super ( Eve , self ) . __init__ ( import_name , ** kwargs ) <EOL> self . logger . addFilter ( RequestFilter ( ) ) <EOL> self . validator = validator <EOL> self . settings = settings <EOL> self . load_config ( ) <EOL> self . validate_domain_struct ( ) <EOL> self . url_map . converters [ '<STR_LIT>' ] = RegexConverter <EOL> if url_converters : <EOL> self . url_map . converters . update ( url_converters ) <EOL> self . data = data ( self ) <EOL> if json_encoder : <EOL> self . data . json_encoder_class = json_encoder <EOL> self . media = media ( self ) if media else None <EOL> self . redis = redis <EOL> if auth : <EOL> self . auth = auth ( ) if callable ( auth ) else auth <EOL> else : <EOL> self . auth = None <EOL> self . _init_url_rules ( ) <EOL> self . _init_media_endpoint ( ) <EOL> self . _init_schema_endpoint ( ) <EOL> if self . config [ '<STR_LIT>' ] is True : <EOL> self . _init_oplog ( ) <EOL> domain_copy = copy . deepcopy ( self . config [ '<STR_LIT>' ] ) <EOL> for resource , settings in domain_copy . items ( ) : <EOL> self . register_resource ( resource , settings ) <EOL> self . register_error_handlers ( ) <EOL> def run ( self , host = None , port = None , debug = None , ** options ) : <EOL> """<STR_LIT>""" <EOL> options . setdefault ( '<STR_LIT>' , EveWSGIRequestHandler ) <EOL> super ( Eve , self ) . run ( host , port , debug , ** options ) <EOL> def load_config ( self ) : <EOL> """<STR_LIT>""" <EOL> self . config . from_object ( '<STR_LIT>' ) <EOL> if isinstance ( self . settings , dict ) : <EOL> self . config . update ( self . settings ) <EOL> else : <EOL> if os . path . isabs ( self . settings ) : <EOL> pyfile = self . settings <EOL> else : <EOL> abspath = os . path . abspath ( os . path . dirname ( sys . argv [ <NUM_LIT:0> ] ) ) <EOL> pyfile = os . path . join ( abspath , self . settings ) <EOL> try : <EOL> self . config . from_pyfile ( pyfile ) <EOL> except IOError : <EOL> pass <EOL> except : <EOL> raise <EOL> envvar = '<STR_LIT>' <EOL> if os . environ . get ( envvar ) : <EOL> self . config . from_envvar ( envvar ) <EOL> def validate_domain_struct ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> domain = self . config [ '<STR_LIT>' ] <EOL> except : <EOL> raise ConfigException ( '<STR_LIT>' ) <EOL> if not isinstance ( domain , dict ) : <EOL> raise ConfigException ( '<STR_LIT>' ) <EOL> def validate_config ( self ) : <EOL> """<STR_LIT>""" <EOL> self . validate_methods ( self . supported_resource_methods , <EOL> self . config . get ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> self . validate_methods ( self . supported_item_methods , <EOL> self . config . get ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> for resource , settings in self . config [ '<STR_LIT>' ] . items ( ) : <EOL> self . _validate_resource_settings ( resource , settings ) <EOL> def _validate_resource_settings ( self , resource , settings ) : <EOL> """<STR_LIT>""" <EOL> self . validate_methods ( self . supported_resource_methods , <EOL> settings [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' % resource ) <EOL> self . validate_methods ( self . supported_item_methods , <EOL> settings [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' % resource ) <EOL> if '<STR_LIT:POST>' in settings [ '<STR_LIT>' ] or '<STR_LIT>' in settings [ '<STR_LIT>' ] : <EOL> if len ( settings [ '<STR_LIT>' ] ) == <NUM_LIT:0> : <EOL> raise ConfigException ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % resource ) <EOL> self . validate_roles ( '<STR_LIT>' , settings , resource ) <EOL> self . validate_roles ( '<STR_LIT>' , settings , resource ) <EOL> self . validate_roles ( '<STR_LIT>' , settings , resource ) <EOL> self . validate_roles ( '<STR_LIT>' , settings , resource ) <EOL> self . validate_roles ( '<STR_LIT>' , settings , resource ) <EOL> self . validate_roles ( '<STR_LIT>' , settings , resource ) <EOL> if settings [ '<STR_LIT>' ] == settings [ '<STR_LIT>' ] : <EOL> raise ConfigException ( '<STR_LIT>' <EOL> '<STR_LIT>' % ( resource , settings [ '<STR_LIT>' ] ) ) <EOL> self . validate_schema ( resource , settings [ '<STR_LIT>' ] ) <EOL> def validate_roles ( self , directive , candidate , resource ) : <EOL> """<STR_LIT>""" <EOL> roles = candidate [ directive ] <EOL> if not isinstance ( roles , list ) : <EOL> raise ConfigException ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( directive , resource ) ) <EOL> def validate_methods ( self , allowed , proposed , item ) : <EOL> """<STR_LIT>""" <EOL> diff = set ( proposed ) - set ( allowed ) <EOL> if diff : <EOL> raise ConfigException ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( item , '<STR_LIT:U+002CU+0020>' . join ( diff ) , <EOL> '<STR_LIT:U+002CU+0020>' . join ( allowed ) ) ) <EOL> def validate_schema ( self , resource , schema ) : <EOL> """<STR_LIT>""" <EOL> def validate_field_name ( field ) : <EOL> forbidden = [ '<STR_LIT:$>' , '<STR_LIT:.>' ] <EOL> if any ( x in field for x in forbidden ) : <EOL> raise SchemaException ( <EOL> "<STR_LIT>" % <EOL> ( field , '<STR_LIT:U+002CU+0020>' . join ( forbidden ) ) ) <EOL> resource_settings = self . config [ '<STR_LIT>' ] [ resource ] <EOL> fields = [ eve . DATE_CREATED , eve . LAST_UPDATED , eve . ETAG ] <EOL> if resource_settings [ '<STR_LIT>' ] is True : <EOL> fields += [ <EOL> self . config [ '<STR_LIT>' ] , <EOL> self . config [ '<STR_LIT>' ] , <EOL> resource_settings [ '<STR_LIT>' ] + <EOL> self . config [ '<STR_LIT>' ] ] <EOL> if resource_settings [ '<STR_LIT>' ] is True : <EOL> fields += [ self . config [ '<STR_LIT>' ] ] <EOL> offenders = [ ] <EOL> for field in fields : <EOL> if field in schema : <EOL> offenders . append ( field ) <EOL> if offenders : <EOL> raise SchemaException ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> % ( '<STR_LIT:U+002CU+0020>' . join ( offenders ) , resource ) ) <EOL> for field , ruleset in schema . items ( ) : <EOL> validate_field_name ( field ) <EOL> if '<STR_LIT>' in ruleset . get ( '<STR_LIT:type>' , '<STR_LIT>' ) : <EOL> for field in ruleset . get ( '<STR_LIT>' , { } ) . keys ( ) : <EOL> validate_field_name ( field ) <EOL> if '<STR_LIT>' in ruleset : <EOL> if '<STR_LIT>' not in ruleset [ '<STR_LIT>' ] : <EOL> raise SchemaException ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( resource , field ) ) <EOL> if ruleset [ '<STR_LIT>' ] . get ( '<STR_LIT>' , False ) : <EOL> value_field = ruleset [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> if ruleset [ '<STR_LIT>' ] . get ( '<STR_LIT:version>' , False ) : <EOL> if '<STR_LIT>' not in ruleset or value_field not in ruleset [ '<STR_LIT>' ] or '<STR_LIT:type>' not in ruleset [ '<STR_LIT>' ] [ value_field ] : <EOL> raise SchemaException ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % value_field <EOL> ) <EOL> def set_defaults ( self ) : <EOL> """<STR_LIT>""" <EOL> for resource , settings in self . config [ '<STR_LIT>' ] . items ( ) : <EOL> self . _set_resource_defaults ( resource , settings ) <EOL> def _set_resource_defaults ( self , resource , settings ) : <EOL> """<STR_LIT>""" <EOL> settings . setdefault ( '<STR_LIT:url>' , resource ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , settings [ '<STR_LIT:url>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> resource . rstrip ( '<STR_LIT:s>' ) . capitalize ( ) ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , [ ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , None ) <EOL> if settings [ '<STR_LIT>' ] : <EOL> item_methods = self . config [ '<STR_LIT>' ] <EOL> else : <EOL> item_methods = eve . ITEM_METHODS <EOL> settings . setdefault ( '<STR_LIT>' , item_methods ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , { } ) <EOL> settings . setdefault ( '<STR_LIT>' , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> settings . setdefault ( '<STR_LIT>' , self . auth if self . auth else None ) <EOL> schema = settings . setdefault ( '<STR_LIT>' , { } ) <EOL> self . set_schema_defaults ( schema , settings [ '<STR_LIT>' ] ) <EOL> settings [ '<STR_LIT>' ] = build_defaults ( schema ) <EOL> settings [ '<STR_LIT>' ] = [ field for field , definition in schema . items ( ) if <EOL> definition . get ( '<STR_LIT:type>' ) == '<STR_LIT>' ] <EOL> if settings [ '<STR_LIT>' ] and not self . media : <EOL> raise ConfigException ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _set_resource_datasource ( resource , schema , settings ) <EOL> def _set_resource_datasource ( self , resource , schema , settings ) : <EOL> """<STR_LIT>""" <EOL> settings . setdefault ( '<STR_LIT>' , { } ) <EOL> ds = settings [ '<STR_LIT>' ] <EOL> ds . setdefault ( '<STR_LIT:source>' , resource ) <EOL> ds . setdefault ( '<STR_LIT>' , None ) <EOL> ds . setdefault ( '<STR_LIT>' , None ) <EOL> self . _set_resource_projection ( ds , schema , settings ) <EOL> aggregation = ds . setdefault ( '<STR_LIT>' , None ) <EOL> if aggregation : <EOL> aggregation . setdefault ( '<STR_LIT>' , { } ) <EOL> settings [ '<STR_LIT>' ] = [ '<STR_LIT:GET>' ] <EOL> settings [ '<STR_LIT>' ] = False <EOL> def _set_resource_projection ( self , ds , schema , settings ) : <EOL> """<STR_LIT>""" <EOL> projection = ds . get ( '<STR_LIT>' , { } ) <EOL> exclusion = any ( ( ( k , v ) for k , v in projection . items ( ) if v == <NUM_LIT:0> ) ) if projection else None <EOL> if not exclusion and len ( schema ) and settings [ '<STR_LIT>' ] is False : <EOL> if not projection : <EOL> projection . update ( dict ( ( field , <NUM_LIT:1> ) for ( field ) in schema ) ) <EOL> projection [ settings [ '<STR_LIT>' ] ] = <NUM_LIT:1> <EOL> projection [ self . config [ '<STR_LIT>' ] ] = <NUM_LIT:1> <EOL> projection [ self . config [ '<STR_LIT>' ] ] = <NUM_LIT:1> <EOL> projection [ self . config [ '<STR_LIT>' ] ] = <NUM_LIT:1> <EOL> if settings [ '<STR_LIT>' ] is True : <EOL> projection [ self . config [ '<STR_LIT>' ] ] = <NUM_LIT:1> <EOL> projection [ <EOL> settings [ '<STR_LIT>' ] + <EOL> self . config [ '<STR_LIT>' ] ] = <NUM_LIT:1> <EOL> else : <EOL> projection = None <EOL> ds . setdefault ( '<STR_LIT>' , projection ) <EOL> if settings [ '<STR_LIT>' ] is True and not exclusion and ds [ '<STR_LIT>' ] is not None : <EOL> ds [ '<STR_LIT>' ] [ self . config [ '<STR_LIT>' ] ] = <NUM_LIT:1> <EOL> settings [ '<STR_LIT>' ] = build_defaults ( schema ) <EOL> settings [ '<STR_LIT>' ] = [ field for field , definition in schema . items ( ) if <EOL> definition . get ( '<STR_LIT:type>' ) == '<STR_LIT>' ] <EOL> if settings [ '<STR_LIT>' ] and not self . media : <EOL> raise ConfigException ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def set_schema_defaults ( self , schema , id_field ) : <EOL> """<STR_LIT>""" <EOL> schema . setdefault ( id_field , { '<STR_LIT:type>' : '<STR_LIT>' } ) <EOL> for data_relation in list ( extract_key_values ( '<STR_LIT>' , schema ) ) : <EOL> data_relation . setdefault ( '<STR_LIT>' , id_field ) <EOL> @ property <EOL> def api_prefix ( self ) : <EOL> """<STR_LIT>""" <EOL> return api_prefix ( self . config [ '<STR_LIT>' ] , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> def _add_resource_url_rules ( self , resource , settings ) : <EOL> """<STR_LIT>""" <EOL> self . config [ '<STR_LIT>' ] [ resource ] = settings [ '<STR_LIT>' ] <EOL> if settings [ '<STR_LIT>' ] : <EOL> return <EOL> url = '<STR_LIT>' % ( self . api_prefix , settings [ '<STR_LIT:url>' ] ) <EOL> pretty_url = settings [ '<STR_LIT:url>' ] <EOL> if '<STR_LIT:<>' in pretty_url : <EOL> pretty_url = pretty_url [ : pretty_url . index ( '<STR_LIT:<>' ) + <NUM_LIT:1> ] + pretty_url [ pretty_url . rindex ( '<STR_LIT::>' ) + <NUM_LIT:1> : ] <EOL> self . config [ '<STR_LIT>' ] [ resource ] = pretty_url <EOL> endpoint = resource + "<STR_LIT>" <EOL> self . add_url_rule ( url , endpoint , view_func = collections_endpoint , <EOL> methods = settings [ '<STR_LIT>' ] + [ '<STR_LIT>' ] ) <EOL> if settings [ '<STR_LIT>' ] : <EOL> item_url = '<STR_LIT>' % ( url , settings [ '<STR_LIT>' ] , <EOL> settings [ '<STR_LIT>' ] ) <EOL> endpoint = resource + "<STR_LIT>" <EOL> self . add_url_rule ( item_url , endpoint , <EOL> view_func = item_endpoint , <EOL> methods = settings [ '<STR_LIT>' ] + [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in settings [ '<STR_LIT>' ] : <EOL> endpoint = resource + "<STR_LIT>" <EOL> self . add_url_rule ( item_url , endpoint , view_func = item_endpoint , <EOL> methods = [ '<STR_LIT:POST>' ] ) <EOL> lookup = settings . get ( '<STR_LIT>' ) <EOL> if lookup : <EOL> l_type = settings [ '<STR_LIT>' ] [ lookup [ '<STR_LIT>' ] ] [ '<STR_LIT:type>' ] <EOL> if l_type == '<STR_LIT>' : <EOL> item_url = '<STR_LIT>' % ( url , lookup [ '<STR_LIT>' ] ) <EOL> else : <EOL> item_url = '<STR_LIT>' % ( url , lookup [ '<STR_LIT:url>' ] , <EOL> lookup [ '<STR_LIT>' ] ) <EOL> endpoint = resource + "<STR_LIT>" <EOL> self . add_url_rule ( item_url , endpoint , view_func = item_endpoint , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT>' ] ) <EOL> def _init_url_rules ( self ) : <EOL> """<STR_LIT>""" <EOL> self . config [ '<STR_LIT>' ] = { } <EOL> self . config [ '<STR_LIT>' ] = { } <EOL> self . url_map . strict_slashes = False <EOL> self . add_url_rule ( '<STR_LIT>' % self . api_prefix , '<STR_LIT>' , <EOL> view_func = home_endpoint , methods = [ '<STR_LIT:GET>' , '<STR_LIT>' ] ) <EOL> def register_resource ( self , resource , settings ) : <EOL> """<STR_LIT>""" <EOL> self . config [ '<STR_LIT>' ] [ resource ] = settings <EOL> self . _set_resource_defaults ( resource , settings ) <EOL> self . _validate_resource_settings ( resource , settings ) <EOL> self . _add_resource_url_rules ( resource , settings ) <EOL> if settings [ '<STR_LIT>' ] is True : <EOL> versioned_resource = resource + self . config [ '<STR_LIT>' ] <EOL> self . config [ '<STR_LIT>' ] [ versioned_resource ] = copy . deepcopy ( self . config [ '<STR_LIT>' ] [ resource ] ) <EOL> self . config [ '<STR_LIT>' ] [ versioned_resource ] [ '<STR_LIT>' ] [ '<STR_LIT:source>' ] += self . config [ '<STR_LIT>' ] <EOL> self . config [ '<STR_LIT>' ] [ versioned_resource ] = copy . deepcopy ( self . config [ '<STR_LIT>' ] [ resource ] ) <EOL> self . config [ '<STR_LIT>' ] [ versioned_resource ] [ '<STR_LIT:source>' ] += self . config [ '<STR_LIT>' ] <EOL> self . _add_resource_url_rules ( <EOL> versioned_resource , <EOL> self . config [ '<STR_LIT>' ] [ versioned_resource ] <EOL> ) <EOL> mongo_indexes = self . config [ '<STR_LIT>' ] [ resource ] [ '<STR_LIT>' ] <EOL> if mongo_indexes : <EOL> for name , value in mongo_indexes . items ( ) : <EOL> if isinstance ( value , tuple ) : <EOL> list_of_keys , index_options = value <EOL> else : <EOL> list_of_keys = value <EOL> index_options = { } <EOL> create_index ( self , resource , name , list_of_keys , index_options ) <EOL> def register_error_handlers ( self ) : <EOL> """<STR_LIT>""" <EOL> for code in self . config [ '<STR_LIT>' ] : <EOL> self . error_handler_spec [ None ] [ code ] = error_endpoint <EOL> def _init_oplog ( self ) : <EOL> """<STR_LIT>""" <EOL> name , endpoint , audit , extra = ( <EOL> self . config [ '<STR_LIT>' ] , <EOL> self . config [ '<STR_LIT>' ] , <EOL> self . config [ '<STR_LIT>' ] , <EOL> self . config [ '<STR_LIT>' ] <EOL> ) <EOL> settings = self . config [ '<STR_LIT>' ] . setdefault ( name , { } ) <EOL> settings . setdefault ( '<STR_LIT>' , { '<STR_LIT:source>' : name } ) <EOL> settings [ '<STR_LIT>' ] = [ '<STR_LIT:GET>' ] <EOL> settings [ '<STR_LIT>' ] = [ '<STR_LIT:GET>' ] <EOL> if endpoint : <EOL> settings . setdefault ( '<STR_LIT:url>' , endpoint ) <EOL> settings [ '<STR_LIT>' ] = False <EOL> else : <EOL> settings [ '<STR_LIT:url>' ] = name <EOL> settings [ '<STR_LIT>' ] = True <EOL> settings [ '<STR_LIT>' ] = { <EOL> '<STR_LIT:r>' : { } , <EOL> '<STR_LIT:o>' : { } , <EOL> '<STR_LIT:i>' : { } , <EOL> } <EOL> if extra : <EOL> settings [ '<STR_LIT>' ] . update ( <EOL> { '<STR_LIT>' : { } } <EOL> ) <EOL> if audit : <EOL> settings [ '<STR_LIT>' ] . update ( <EOL> { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT:c>' : { } , <EOL> '<STR_LIT:u>' : { } , <EOL> } <EOL> ) <EOL> def _init_media_endpoint ( self ) : <EOL> endpoint = self . config [ '<STR_LIT>' ] <EOL> if endpoint : <EOL> media_url = '<STR_LIT>' % ( self . api_prefix , <EOL> endpoint , <EOL> self . config [ '<STR_LIT>' ] ) <EOL> self . add_url_rule ( media_url , '<STR_LIT>' , <EOL> view_func = media_endpoint , methods = [ '<STR_LIT:GET>' ] ) <EOL> def _init_schema_endpoint ( self ) : <EOL> """<STR_LIT>""" <EOL> endpoint = self . config [ '<STR_LIT>' ] <EOL> if endpoint : <EOL> schema_url = '<STR_LIT>' % ( self . api_prefix , endpoint ) <EOL> self . add_url_rule ( schema_url , '<STR_LIT>' , <EOL> view_func = schema_collection_endpoint , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT>' ] ) <EOL> self . add_url_rule ( schema_url + '<STR_LIT>' , '<STR_LIT>' , <EOL> view_func = schema_item_endpoint , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT>' ] ) <EOL> def __call__ ( self , environ , start_response ) : <EOL> """<STR_LIT>""" <EOL> if self . config [ '<STR_LIT>' ] : <EOL> environ [ '<STR_LIT>' ] = environ . get ( <EOL> '<STR_LIT>' , <EOL> environ [ '<STR_LIT>' ] ) . upper ( ) <EOL> return super ( Eve , self ) . __call__ ( environ , start_response ) </s>
