X7ROOT File Manager
Current Path:
/opt/alt/python37/lib/python3.7/site-packages/validators
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
validators
/
📁
..
📄
__init__.py
(1.08 KB)
📁
__pycache__
📄
between.py
(1.54 KB)
📄
btc_address.py
(1.49 KB)
📄
card.py
(4.28 KB)
📄
domain.py
(1.29 KB)
📄
email.py
(1.93 KB)
📄
extremes.py
(991 B)
📄
hashes.py
(2.44 KB)
📁
i18n
📄
iban.py
(1.14 KB)
📄
ip_address.py
(3.99 KB)
📄
length.py
(970 B)
📄
mac_address.py
(836 B)
📄
slug.py
(529 B)
📄
truthy.py
(876 B)
📄
url.py
(4.82 KB)
📄
utils.py
(1.97 KB)
📄
uuid.py
(970 B)
Editing: iban.py
import re from .utils import validator regex = ( r'^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$' ) pattern = re.compile(regex) def char_value(char): """A=10, B=11, ..., Z=35 """ if char.isdigit(): return int(char) else: return 10 + ord(char) - ord('A') def modcheck(value): """Check if the value string passes the mod97-test. """ # move country code and check numbers to end rearranged = value[4:] + value[:4] # convert letters to numbers converted = [char_value(char) for char in rearranged] # interpret as integer integerized = int(''.join([str(i) for i in converted])) return (integerized % 97 == 1) @validator def iban(value): """ Return whether or not given value is a valid IBAN code. If the value is a valid IBAN this function returns ``True``, otherwise :class:`~validators.utils.ValidationFailure`. Examples:: >>> iban('DE29100500001061045672') True >>> iban('123456') ValidationFailure(func=iban, ...) .. versionadded:: 0.8 :param value: IBAN string to validate """ return pattern.match(value) and modcheck(value)
Upload File
Create Folder