Source code for deep_translator.validate
__copyright__ = "Copyright (C) 2020 Nidhal Baccouri"
from typing import Optional
from deep_translator.exceptions import NotValidLength, NotValidPayload
[docs]def is_empty(text: str) -> bool:
return text == ""
[docs]def request_failed(status_code: int) -> bool:
"""Check if a request has failed or not.
A request is considered successfull if the status code is in the 2** range.
Args:
status_code (int): status code of the request
Returns:
bool: indicates request failure
"""
if status_code > 299 or status_code < 200:
return True
return False