<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_op_for_request(request, route_info, spec):
 """ Find out which operation in the Swagger schema corresponds to the given pyramid request. :type request: :class:`pyramid.request.Request` :type route_info: dict (usually has 'match' and 'route' keys) :type spec: :class:`bravado_core.spec.Spec` :rtype: :class:`bravado_core.operation.Operation` :raises: PathNotMatchedError when a matching Swagger operation is not found. """

    # pyramid.urldispath.Route
    route = route_info['route']
    if hasattr(route, 'path'):
        route_path = route.path
        if route_path[0] != '/':
            route_path = '/' + route_path
        op = spec.get_op_for_request(request.method, route_path)
        if op is not None:
            return op
        else:
            raise PathNotMatchedError(
                "Could not find a matching Swagger "
                "operation for {0} request {1}"
                .format(request.method, request.url))
    else:
        raise PathNotMatchedError(
            "Could not find a matching route for {0} request {1}. "
            "Have you registered this endpoint with Pyramid?"
            .format(request.method, request.url))