(application)
return lint_app
When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliance on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliance on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
When applied between a WSGI server and a WSGI application this middleware will check for WSGI compliance on a number of levels . This middleware does not modify the request or response in any way but will raise an AssertionError if anything seems off ( except for a failure to close the application iterator which will be printed to stderr -- there s no way to raise an exception at that point ) .
def validator(application):

    """
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliance on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    """

    def lint_app(*args, **kw):
        assert_(len(args) == 2, "Two arguments required")
        assert_(not kw, "No keyword arguments allowed")
        environ, start_response = args

        check_environ(environ)

        # We use this to check if the application returns without
        # calling start_response:
        start_response_started = []

        def start_response_wrapper(*args, **kw):
            assert_(len(args) == 2 or len(args) == 3, (
                "Invalid number of arguments: %s" % (args,)))
            assert_(not kw, "No keyword arguments allowed")
            status = args[0]
            headers = args[1]
            if len(args) == 3:
                exc_info = args[2]
            else:
                exc_info = None

            check_status(status)
            check_headers(headers)
            check_content_type(status, headers)
            check_exc_info(exc_info)

            start_response_started.append(None)
            return WriteWrapper(start_response(*args))

        environ['wsgi.input'] = InputWrapper(environ['wsgi.input'])
        environ['wsgi.errors'] = ErrorWrapper(environ['wsgi.errors'])

        iterator = application(environ, start_response_wrapper)
        assert_(iterator is not None and iterator != False,
            "The application must return an iterator, if only an empty list")

        check_iterator(iterator)

        return IteratorWrapper(iterator, start_response_started)

    return lint_app
def validator ( application ) : def lint_app ( * args , * * kw ) : assert_ ( len ( args ) == 2 , "Two arguments required" ) assert_ ( not kw , "No keyword arguments allowed" ) environ , start_response = args check_environ ( environ ) # We use this to check if the application returns without # calling start_response: start_response_started = [ ] def start_response_wrapper ( * args , * * kw ) : assert_ ( len ( args ) == 2 or len ( args ) == 3 , ( "Invalid number of arguments: %s" % ( args , ) ) ) assert_ ( not kw , "No keyword arguments allowed" ) status = args [ 0 ] headers = args [ 1 ] if len ( args ) == 3 : exc_info = args [ 2 ] else : exc_info = None check_status ( status ) check_headers ( headers ) check_content_type ( status , headers ) check_exc_info ( exc_info ) start_response_started . append ( None ) return WriteWrapper ( start_response ( * args ) ) environ [ 'wsgi.input' ] = InputWrapper ( environ [ 'wsgi.input' ] ) environ [ 'wsgi.errors' ] = ErrorWrapper ( environ [ 'wsgi.errors' ] ) iterator = application ( environ , start_response_wrapper ) assert_ ( iterator is not None and iterator != False , "The application must return an iterator, if only an empty list" ) check_iterator ( iterator ) return IteratorWrapper ( iterator , start_response_started ) return lint_app