def analyse_patch_request_errors(request_validator: UserRequest, data: Data, filename: str, class_method: str, method_parameters: dict) \ -> Union[tuple, None]: try: request_validator.existent_filename_validator(filename) except Exception as nonexistent_train_filename: return ( jsonify( {Constants.MESSAGE_RESULT: str(nonexistent_train_filename)}), Constants.HTTP_STATUS_CODE_NOT_FOUND, ) module_path, class_name = data.get_module_and_class(filename) try: request_validator.valid_method_class_validator(module_path, class_name, class_method) except Exception as invalid_method_name: return ( jsonify({Constants.MESSAGE_RESULT: str(invalid_method_name)}), Constants.HTTP_STATUS_CODE_NOT_ACCEPTABLE, ) try: request_validator.valid_method_parameters_name_validator( module_path, class_name, class_method, method_parameters) except Exception as invalid_function_parameters: return ( jsonify( {Constants.MESSAGE_RESULT: str(invalid_function_parameters)}), Constants.HTTP_STATUS_CODE_NOT_ACCEPTABLE, ) return None
def analyse_post_request_errors(request_validator: UserRequest, filename: str, module_path: str, class_name: str, class_parameters: dict, class_method: str, method_parameters: dict) \ -> Union[tuple, None]: try: request_validator.not_duplicated_filename_validator(filename) except Exception as duplicated_filename: return ( jsonify({Constants.MESSAGE_RESULT: str(duplicated_filename)}), Constants.HTTP_STATUS_CODE_CONFLICT, ) try: request_validator.available_module_path_validator(module_path) except Exception as invalid_tool_name: return ( jsonify({Constants.MESSAGE_RESULT: str(invalid_tool_name)}), Constants.HTTP_STATUS_CODE_NOT_ACCEPTABLE, ) try: request_validator.valid_class_validator(module_path, class_name) except Exception as invalid_function_name: return ( jsonify({Constants.MESSAGE_RESULT: str(invalid_function_name)}), Constants.HTTP_STATUS_CODE_NOT_ACCEPTABLE, ) try: request_validator.valid_class_parameters_validator( module_path, class_name, class_parameters) except Exception as invalid_function_parameters: return ( jsonify( {Constants.MESSAGE_RESULT: str(invalid_function_parameters)}), Constants.HTTP_STATUS_CODE_NOT_ACCEPTABLE, ) try: request_validator.valid_method_class_validator(module_path, class_name, class_method) except Exception as invalid_method_name: return ( jsonify({Constants.MESSAGE_RESULT: str(invalid_method_name)}), Constants.HTTP_STATUS_CODE_NOT_ACCEPTABLE, ) try: request_validator.valid_method_parameters_name_validator( module_path, class_name, class_method, method_parameters) except Exception as invalid_method_parameters: return ( jsonify({Constants.MESSAGE_RESULT: str(invalid_method_parameters)}), Constants.HTTP_STATUS_CODE_NOT_ACCEPTABLE, ) return None