arpakitlib 1.8.240__py3-none-any.whl → 1.8.241__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ import logging
2
+
3
+ import email_validator
4
+ import pydantic
5
+
6
+ _logger = logging.getLogger(__name__)
7
+
8
+
9
+ class ReallyValidateEmailException(Exception):
10
+ def __init__(self, email: str, error_message: str):
11
+ self.email = email
12
+ self.error_message = error_message
13
+
14
+ def __str__(self) -> str:
15
+ return f"{self.__class__.__name__}, {self.email=}, {self.error_message}"
16
+
17
+ def __repr__(self) -> str:
18
+ return f"{self.__class__.__name__}, {self.email=}, {self.error_message}"
19
+
20
+
21
+ def really_validate_email(email: str, *, log_exception: bool = True):
22
+ try:
23
+ pydantic.validate_email(value=email)
24
+ email_validator.validate_email(email)
25
+ except Exception as exception:
26
+ if log_exception:
27
+ _logger.warning(exception)
28
+ raise ReallyValidateEmailException(
29
+ email=email,
30
+ error_message=str(exception)
31
+ )
32
+
33
+
34
+ def is_really_email_valid(email: str) -> bool:
35
+ try:
36
+ really_validate_email(email=email, log_exception=False)
37
+ except ReallyValidateEmailException:
38
+ return False
39
+ return True
40
+
41
+
42
+ def __example():
43
+ print(is_really_email_valid("asfas@mail.sex"))
44
+
45
+
46
+ if __name__ == '__main__':
47
+ __example()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: arpakitlib
3
- Version: 1.8.240
3
+ Version: 1.8.241
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
@@ -423,8 +423,9 @@ arpakitlib/ar_yookassa_api_client_util.py,sha256=VozuZeCJjmLd1zj2BdC9WfiAQ3XYOrI
423
423
  arpakitlib/clone_pydantic_model_fields.py,sha256=xxLwtvJzDf8EWMvBE4psWIj8c-cyeCxLRX76oCY_4zk,1214
424
424
  arpakitlib/pydantic_schema_from_sqlalchemy_model.py,sha256=_5Y79kQ4lLIOL6_afIFVwxY1EXzTMpi-veRR-WkPFOs,2879
425
425
  arpakitlib/raise_own_exception_if_exception.py,sha256=A6TuNSBk1pHaQ_qxnUmE2LgsNGA1IGqX26b1_HEA4Nc,5978
426
- arpakitlib-1.8.240.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
427
- arpakitlib-1.8.240.dist-info/METADATA,sha256=NCPpuCaFFTzOWrpvUv33pTBbLBrPr8wpe6y3bPtOQJo,3741
428
- arpakitlib-1.8.240.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
429
- arpakitlib-1.8.240.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
430
- arpakitlib-1.8.240.dist-info/RECORD,,
426
+ arpakitlib/really_validate_email.py,sha256=HBfhyiDB3INI6Iq6hR2WOMKA5wVWWRl0Qun-x__OZ9o,1201
427
+ arpakitlib-1.8.241.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
428
+ arpakitlib-1.8.241.dist-info/METADATA,sha256=9zdoYCPTVYXqGyVzyYxF0Pgde5y0JldKABXsc0XSFj4,3741
429
+ arpakitlib-1.8.241.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
430
+ arpakitlib-1.8.241.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
431
+ arpakitlib-1.8.241.dist-info/RECORD,,