X7ROOT File Manager
Current Path:
/opt/alt/python311/lib/python3.11/site-packages/validators
opt
/
alt
/
python311
/
lib
/
python3.11
/
site-packages
/
validators
/
📁
..
📄
__init__.py
(1.86 KB)
📁
__pycache__
📄
_extremes.py
(1.01 KB)
📄
_tld.txt
(9.4 KB)
📄
between.py
(2.39 KB)
📄
btc_address.py
(1.62 KB)
📄
card.py
(5.63 KB)
📄
country.py
(14.57 KB)
📄
cron.py
(2.23 KB)
📄
domain.py
(2.4 KB)
📄
email.py
(2.72 KB)
📄
encoding.py
(1.34 KB)
📄
finance.py
(3.22 KB)
📄
hashes.py
(3.21 KB)
📄
hostname.py
(4.05 KB)
📁
i18n
📄
iban.py
(1.05 KB)
📄
ip_address.py
(4.34 KB)
📄
length.py
(1.45 KB)
📄
mac_address.py
(865 B)
📄
py.typed
(0 B)
📄
slug.py
(750 B)
📄
uri.py
(1.78 KB)
📄
url.py
(7.23 KB)
📄
utils.py
(3.1 KB)
📄
uuid.py
(1.04 KB)
Editing: uri.py
"""URI.""" # Read: https://stackoverflow.com/questions/176264 # https://www.rfc-editor.org/rfc/rfc3986#section-3 # local from .email import email from .url import url from .utils import validator def _file_url(value: str): if not value.startswith("file:///"): return False return True def _ipfs_url(value: str): if not value.startswith("ipfs://"): return False return True @validator def uri(value: str, /): """Return whether or not given value is a valid URI. Examples: >>> uri('mailto:example@domain.com') # Output: True >>> uri('file:path.txt') # Output: ValidationError(func=uri, ...) Args: value: URI to validate. Returns: (Literal[True]): If `value` is a valid URI. (ValidationError): If `value` is an invalid URI. """ if not value: return False # TODO: work on various validations # url if any( # fmt: off value.startswith(item) for item in { "ftp", "ftps", "git", "http", "https", "irc", "rtmp", "rtmps", "rtsp", "sftp", "ssh", "telnet", } # fmt: on ): return url(value) # email if value.startswith("mailto:"): return email(value.lstrip("mailto:")) # file if value.startswith("file:"): return _file_url(value) # ipfs if value.startswith("ipfs:"): return _ipfs_url(value) # magnet if value.startswith("magnet:?"): return True # telephone if value.startswith("tel:"): return True # data if value.startswith("data:"): return True # urn if value.startswith("urn:"): return True # urc if value.startswith("urc:"): return True return False
Upload File
Create Folder