-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
153 lines (123 loc) · 4.19 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import textwrap
import setuptools
long_description = textwrap.dedent(
"""
# Email Domain Verification Package
this package can provide some email validators with which users can validate their project emails far easily
## Installation
<p>your module will be installed by PYPI</p>
```
pip install email-domain-verification
```
## Usage
```
from email_domain_verification import Email, EmailVerifier
from email_domain_verification.validators import BlackDomainListValidator
# you can import any of these validators or write your own validator
# (
# BlackDomainListValidator,
# DomainExtensionValidator,
# LengthValidator,
# MultiDotValidator,
# SafeDomainValidator,
# SafeDomainValidatorOnline,
# )
email = Email("[email protected]")
black_email_list = [
"xyz-mail.com",
"tempmail.com",
"temp.com",
"mail-temp.org",
# ...
]
validators = [
BlackDomainListValidator(black_email_list),
]
verifier = EmailVerifier(email)
verifier.verify(validators)
```
### prevent raise exception
```
from email_domain_verification import Email, EmailVerifier
from email_domain_verification.validators import BlackDomainListValidator
email = Email("[email protected]")
black_email_list = [
"xyz-mail.com",
"tempmail.com",
# ...
]
validators = [
BlackDomainListValidator(black_email_list),
]
verifier = EmailVerifier(email)
validated: bool = verifier.verify(validators, raise_exception=False)
# validated == True => email is safe | validated == False => email is unsafe
```
## Create Custom Validator
```
from email_domain_verification import Email, EmailVerifier
from email_domain_verification.interfaces import ValidatorInterface
from email_domain_verification.validators import LengthValidator
class CustomValidator(ValidatorInterface):
__criterion: typing.Type
def __init__(self, criterion: typing.Type) -> None:
self.__criterion = criterion
def validate_criterion(self) -> None:
# validate __criterion
pass
def check(self, email: Email) -> bool:
self.validate_criterion()
# check email.value
# example: len(email.value) > self.__criterion: return True
validate = True
if not validate:
raise ValueError("The Error Message")
return True
email = Email("[email protected]")
validators = [
BlackDomainListValidator(black_email_list),
CustomValidator(10),
]
verifier = EmailVerifier(email)
verifier.verify(validators)
```
#### Copyright (c) 2023, Khodnevisai.com (Mahdi Niknejad).
"""
)
if __name__ == "__main__":
setuptools.setup(
name="email_domain_verification",
version="1.1.0",
description="Email Validator",
author="Mahdi Niknejad, Khodnevisai.com",
author_email="[email protected]",
url="https://github.com/Khodnevis-Research-Lab/email-domain-verification",
project_urls={
"Documentation": "https://github.com/Khodnevis-Research-Lab/email-domain-verification",
"Source": "https://github.com/Khodnevis-Research-Lab/email-domain-verification",
"Tracker": "https://github.com/Khodnevis-Research-Lab/email-domain-verification/issues",
},
long_description=long_description,
long_description_content_type="text/markdown",
packages=["email_domain_verification"],
package_data={"email_domain_verification": ["py.typed", "*.pyi"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development",
],
python_requires=">=3.7",
install_requires=[
"requests",
],
)