From ddb08d55fd1e835f66362412d7c7c06e4f5465cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= Date: Fri, 1 Mar 2019 23:29:01 +0100 Subject: [PATCH] Renaming package, adding isort --- .isort.cfg | 3 +++ .travis.yml | 4 ++++ pyemailval/__init__.py | 3 --- requirements.txt | 8 ++++++-- setup.cfg | 4 ---- setup.py | 15 ++++++++------- tests/test_mx_check.py | 3 ++- tests/test_regex_check.py | 3 ++- validate_email/__init__.py | 3 +++ {pyemailval => validate_email}/mx_check.py | 5 +++-- {pyemailval => validate_email}/regex_check.py | 6 +++--- {pyemailval => validate_email}/validate_email.py | 2 +- 12 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 .isort.cfg delete mode 100644 pyemailval/__init__.py create mode 100644 validate_email/__init__.py rename {pyemailval => validate_email}/mx_check.py (98%) rename {pyemailval => validate_email}/regex_check.py (100%) rename {pyemailval => validate_email}/validate_email.py (100%) diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..e948380 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,3 @@ +[settings] +multi_line_output=4 +not_skip=__init__.py diff --git a/.travis.yml b/.travis.yml index f644be5..53d8990 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,11 @@ python: - "3.7-dev" # 3.7 development branch # command to install dependencies install: + - pip install -U pip wheel setuptools + - pip install requirements.txt - pip install -e . # command to run tests script: + - isort --skip-glob=venv + - flake8 tests/ validate_email/ - python -m unittest discover -v diff --git a/pyemailval/__init__.py b/pyemailval/__init__.py deleted file mode 100644 index 764f8f0..0000000 --- a/pyemailval/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from pyemailval.validate_email import validate_email - -validate_email diff --git a/requirements.txt b/requirements.txt index 56966e7..4b34809 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,6 @@ -dnspython -nose +entrypoints==0.3 +flake8==3.7.7 +isort==4.3.9 +mccabe==0.6.1 +pycodestyle==2.5.0 +pyflakes==2.1.1 diff --git a/setup.cfg b/setup.cfg index 712a7c3..5aef279 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,2 @@ -[nosetests] -verbosity=3 -with-doctest=1 - [metadata] description-file = README.rst diff --git a/setup.py b/setup.py index 97f7a89..6a95126 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,17 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup setup( - name='pyemailval', + name='py3-validate-email', version='0.6', - py_modules=('pyemailval',), + py_modules=('validate_email',), install_requires=['dnspython'], - author='Ben Baert', + author='László Károlyi', author_email='laszlo@karolyi.hu', - description='pyemailval verifies if an email address really exists.', + description='Email validator with regex and SMTP checking.', long_description=open('README.rst').read(), keywords='email validation verification mx verify', - url='http://github.com/karolyi/pyemailval', - download_url='http://github.com/karolyi/pyemailval/archive/0.1.tar.gz', + url='http://github.com/karolyi/py3-validate-email', + download_url=( + 'http://github.com/karolyi/py3-validate-email/archive/0.1.tar.gz'), license='LGPL', ) diff --git a/tests/test_mx_check.py b/tests/test_mx_check.py index 03de75e..c7b36dd 100644 --- a/tests/test_mx_check.py +++ b/tests/test_mx_check.py @@ -1,5 +1,6 @@ from unittest.case import TestCase -from pyemailval.mx_check import _get_domain_from_email_address + +from validate_email.mx_check import _get_domain_from_email_address DOMAINS = { 'email@domain.com': 'domain.com', diff --git a/tests/test_regex_check.py b/tests/test_regex_check.py index c4349eb..e36c367 100644 --- a/tests/test_regex_check.py +++ b/tests/test_regex_check.py @@ -1,6 +1,7 @@ -from pyemailval.regex_check import regex_check from unittest.case import TestCase +from validate_email.regex_check import regex_check + VALID_EXAMPLES = [ 'email@domain.com', # basic valid email 'firstname.lastname@domain.com', # dot in address field diff --git a/validate_email/__init__.py b/validate_email/__init__.py new file mode 100644 index 0000000..2edb0c3 --- /dev/null +++ b/validate_email/__init__.py @@ -0,0 +1,3 @@ +from .validate_email import validate_email + +validate_email diff --git a/pyemailval/mx_check.py b/validate_email/mx_check.py similarity index 98% rename from pyemailval/mx_check.py rename to validate_email/mx_check.py index 5fc5311..a1d6b09 100644 --- a/pyemailval/mx_check.py +++ b/validate_email/mx_check.py @@ -1,6 +1,7 @@ import re -import socket import smtplib +import socket + import dns.resolver as dns @@ -18,7 +19,7 @@ def _get_mx_records(domain): records = dns.query(domain, 'MX') except dns.NXDOMAIN: raise ValueError("Domain {} does not seem to exist") - except: + except Exception: raise NotImplementedError("Feature not yet implemented") return [str(x.exchange) for x in records] diff --git a/pyemailval/regex_check.py b/validate_email/regex_check.py similarity index 100% rename from pyemailval/regex_check.py rename to validate_email/regex_check.py index 71ce4a5..48648e6 100644 --- a/pyemailval/regex_check.py +++ b/validate_email/regex_check.py @@ -1,7 +1,7 @@ -from typing import Optional -from re import compile as re_compile -from re import IGNORECASE from ipaddress import IPv4Address, IPv6Address +from re import IGNORECASE +from re import compile as re_compile +from typing import Optional SetOrNone = Optional[set] diff --git a/pyemailval/validate_email.py b/validate_email/validate_email.py similarity index 100% rename from pyemailval/validate_email.py rename to validate_email/validate_email.py index 065f0e7..a76e88b 100644 --- a/pyemailval/validate_email.py +++ b/validate_email/validate_email.py @@ -1,5 +1,5 @@ -from .regex_check import regex_check from .mx_check import mx_check +from .regex_check import regex_check def validate_email(