From d8104dd4da47a6ed7b7c49a27de3a95595c54b64 Mon Sep 17 00:00:00 2001 From: Calina Cenan Date: Thu, 13 Apr 2023 06:47:30 +0000 Subject: [PATCH] Prettier. --- .../validation/provider_requests.py | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/ocean_provider/validation/provider_requests.py b/ocean_provider/validation/provider_requests.py index 438eaa3a..924436f0 100644 --- a/ocean_provider/validation/provider_requests.py +++ b/ocean_provider/validation/provider_requests.py @@ -54,21 +54,28 @@ def __init__(self, request=None): def validate(self): for validator in self._validators: if validator.fails(): - messages = validator.messages() - for overwritable_key in [ - "signature", - "download_signature", - "decrypt_signature", - ]: - if overwritable_key in messages and hasattr( - validator._processor, "signature_error_message" - ): - messages[ - overwritable_key - ] = validator._processor.signature_error_message + messages = self.overwrite_messages(validator) raise ValidationException(messages) return True + def overwrite_messages(self, validator): + messages = validator.messages() + + if not hasattr(validator._processor, "signature_error_message"): + return messages + + for overwritable_key in [ + "signature", + "download_signature", + "decrypt_signature", + ]: + if overwritable_key in messages: + messages[ + overwritable_key + ] = validator._processor.signature_error_message + + return messages + class CustomValidator(Validator): """