Ignore:
Timestamp:
Apr 11, 2020, 4:46:15 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
3db3d13
Parents:
da2be70
Message:
  • Added yapf style config (src/python-style.yapf)
    • Updated all files to the yapf formatted version
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice/server_impl/ValidatorWorkaround.py

    rda2be70 r7be94aa  
    2020
    2121class ValidatorWorkaround(ResponseValidator):
     22    def validate_response_with_request(
     23        self, request, data, status_code, headers, url
     24    ):
     25        if request.headers.get('accept', '') == 'application/geo+json':
     26            logging.debug('Circumventing validation for application/geo+json')
     27            return True
     28        return self.validate_response(data, status_code, headers, url)
    2229
    23         def validate_response_with_request(self, request, data, status_code, headers, url):
    24                 if request.headers.get('accept', '') == 'application/geo+json':
    25                         logging.debug('Circumventing validation for application/geo+json')
    26                         return True
    27                 return self.validate_response(data, status_code, headers, url)
    28 
    29         def __call__(self, function):
    30                 """
     30    def __call__(self, function):
     31        """
    3132                :type function: types.FunctionType
    3233                :rtype: types.FunctionType
    3334                """
    34                 def _wrapper(request, response):
    35                         connexion_response = \
    36                                 self.operation.api.get_connexion_response(response, self.mimetype)
    37                         self.validate_response_with_request(
    38                                 request,
    39                                 connexion_response.body, connexion_response.status_code,
    40                                 connexion_response.headers, request.url)
     35        def _wrapper(request, response):
     36            connexion_response = \
     37             self.operation.api.get_connexion_response(response, self.mimetype)
     38            self.validate_response_with_request(
     39                request, connexion_response.body,
     40                connexion_response.status_code, connexion_response.headers,
     41                request.url
     42            )
    4143
    42                         return response
     44            return response
    4345
    44                 if has_coroutine(function):
    45                         from .coroutine_wrappers import get_response_validator_wrapper
    46                         wrapper = get_response_validator_wrapper(function, _wrapper)
     46        if has_coroutine(function):
     47            from .coroutine_wrappers import get_response_validator_wrapper
     48            wrapper = get_response_validator_wrapper(function, _wrapper)
    4749
    48                 else:  # pragma: 3 no cover
    49                         @functools.wraps(function)
    50                         def wrapper(request):
    51                                 response = function(request)
    52                                 return _wrapper(request, response)
     50        else:  # pragma: 3 no cover
    5351
    54                 return wrapper
     52            @functools.wraps(function)
     53            def wrapper(request):
     54                response = function(request)
     55                return _wrapper(request, response)
     56
     57        return wrapper
Note: See TracChangeset for help on using the changeset viewer.