Permalink
Browse files

changed version to 0.0.0 format, support for travis ci, added unittest

  • Loading branch information...
1 parent c9f5183 commit d61d8c5b67890c6ab2cf6741b55a34f46bbcb117 Val Neekman committed Oct 15, 2012
Showing with 319 additions and 157 deletions.
  1. +3 −11 .gitignore
  2. +7 −0 .travis.yml
  3. +0 −9 HISTORY
  4. +0 −30 LICENSE
  5. +0 −37 README
  6. +110 −0 README.md
  7. +34 −21 emailahoy/__init__.py
  8. +0 −26 emailahoy/utils.py
  9. +5 −0 pep8.sh
  10. +0 −7 pushpi.sh
  11. +1 −0 requirements.txt
  12. +81 −16 setup.py
  13. +78 −0 test.py
View
@@ -1,13 +1,5 @@
*.pyc
-*.pyo
-*.db
-*.swp
-*.log
-.DS_Store
-*~
-dist
-build
MANIFEST
-src
-.svn
-*_db
+dist/
+build/
+*.egg-info/
View
@@ -0,0 +1,7 @@
+language: python
+python:
+ - "2.5"
+ - "2.6"
+ - "2.7"
+script: python test.py
+
View
@@ -1,9 +0,0 @@
-
-- Sept 17, 2012 (v 0.1)
-------------------------
-1. Remove dependency on external packages (pydns)
-
-
-- Sept 16, 2012 (v 0.1)
-------------------------
-1. Initial release
View
30 LICENSE
@@ -1,30 +0,0 @@
-Copyright (c) 2012 Val Neekman (val@neekware.com)
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. Neither the name of this project nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-
View
37 README
@@ -1,37 +0,0 @@
-=Python EmailAhoy=
-
-A Python email utility that verifies existence of an email address
-
-Author: `Val Neekman <val@neekware.com>`
-
-Introduction
-
-Usage Example:
---------------
-
-from emailahoy import VerifyEmail, verify_email_address
-
-# to verify and receive the response status use the class
-##############################################
-e = VerifyEmail()
-status = e.verify_email_smtp('test@example.com')
-if e.was_found(status):
- print >> sys.stderr, "Found:", status
-elif e.not_found(status):
- print >> sys.stderr, "Not Found:", status
-else:
- print >> sys.stderr, "Unverifiable:", status
-
-# to just quickly check if an email exist or not use the shorthand function
-##############################################
-if verify_email_address('test@example.com'):
- print >> sys.stderr, "Found"
-else:
- print >> sys.stderr, "Not found"
-
-# Note:
-##############################################
-If email is valid, this returns within a second
-If email is not valid or unverifiable, it can take up to 5 seconds
-
-
View
110 README.md
@@ -0,0 +1,110 @@
+Python Email Ahoy
+====================
+
+**A Python email utility that verifies existence of an email address**
+
+**Author:** Val Neekman [ info@neekware.com, @vneekman ]
+
+Overview
+========
+
+A Python email utility that verifies existence of an email address.
+
+How to install
+==================
+
+ 1. easy_install python-emailahoy
+ 2. pip install python-emailahoy
+ 3. git clone http://github.com/un33k/python-emailahoy
+ a. cd python-emailahoy
+ b. run python setup.py
+ 4. wget https://github.com/un33k/python-emailahoy/zipball/master
+ a. unzip the downloaded file
+ b. cd into python-emailahoy-* directory
+ c. run python setup.py
+
+How to use
+=================
+
+``Use the class for more control & more granular return status``
+
+ from emailahoy import VerifyEmail
+ e = VerifyEmail()
+ status = e.verify_email_smtp(
+ email='test@example.com',
+ from_host='mydomain.com',
+ from_email='verify@mydomain.com'
+ )
+ if e.was_found(status):
+ print >> sys.stderr, "Found:", status
+ elif e.not_found(status):
+ print >> sys.stderr, "Not Found:", status
+ else:
+ print >> sys.stderr, "Unverifiable:", status
+
+``Use the shorthand function for quick check``
+
+ if verify_email_address('test@example.com'):
+ print >> sys.stderr, "Found"
+ else:
+ print >> sys.stderr, "Don't care"
+
+``Note:``
+ 1. Not all email servers will return the correct status
+ 2. Checking an invalid email address returns within 1 second
+ 3. Checking a valid email address returns within 4 seconds or more
+
+
+Running the tests
+=================
+
+To run the tests against the current environment:
+
+ python test.py
+
+Changelog
+=========
+
+0.0.3
+-----
+* Added Travis CI support
+
+0.2
+-----
+* Removed dependency on external packages (pydns)
+
+0.1
+-----
+
+* Initial release
+
+
+License
+=======
+
+Copyright (c) 2012, Val Neekman
+Neekware Inc.
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
View
@@ -1,13 +1,36 @@
# -*- coding: utf-8 -*-
+__version__ = '0.0.3'
+
import sys
import smtplib
import socket
import re
-from utils import query_mx
+import popen2
+
+__all__ = ['VerifyEmail', 'verify_email_address', 'query_mx']
+
+mx_re = re.compile('mail\sexchanger\s=\s(\d+)\s(.*)\.')
-# only allow the import of our public APIs (UU-SLUG = Uniqure & Unicode Slug)
-__all__ = ['VerifyEmail', 'verify_email_address']
+def query_mx(host):
+ """ Returns all MX records of a given domain name """
+
+ mx = []
+ addr = {}
+ fout, fin = popen2.popen2('which nslookup')
+ cmd = fout.readline().strip()
+ if cmd <> '':
+ fout, fin = popen2.popen2('%s -query=mx %s' % (cmd, host))
+ line = fout.readline()
+ while line <> '':
+ m = mx_re.search(line.lower())
+ if m:
+ mx.append((eval(m.group(1)), m.group(2)))
+ line = fout.readline()
+
+ if mx:
+ mx.sort()
+ return mx
class VerifyEmail(object):
@@ -50,7 +73,7 @@ def get_hostname_from_email(self, email):
# given a hostname, a smtp server connection is returned or None
def get_smtp_connection(self, hostname):
- """ returns server with valid connection if possible """
+ """ returns a server with valid connection if possible """
resp = self.default_response
connection_success = lambda x: x[0] == 220
if self.is_hostname_valid(hostname):
@@ -126,26 +149,16 @@ def verify_email_smtp(
return resp
# given an email it returns True if it can tell it exist or False
-def verify_email_address(email):
+def verify_email_address(
+ email,
+ from_host='example.com',
+ from_email='verify@example.com'
+ ):
+ """ A quick email verification fuction """
e = VerifyEmail()
- status = e.verify_email_smtp(email)
+ status = e.verify_email_smtp(email=email, from_host='example.com', from_email='verify@example.com')
if e.was_found(status):
return True
return False
-# if __name__ == "__main__":
-# # e = VerifyEmail()
-# # status = e.verify_email_smtp(sys.argv[1])
-# # if e.was_found(status):
-# # print >> sys.stderr, "Found:", status
-# # elif e.not_found(status):
-# # print >> sys.stderr, "Not Found:", status
-# # else:
-# # print >> sys.stderr, "Unverifiable:", status
-#
-# if verify_email_address(sys.argv[1]):
-# print >> sys.stderr, "Found"
-# else:
-# print >> sys.stderr, "Not found"
-
View
@@ -1,26 +0,0 @@
-import popen2
-import re
-
-mx_re = re.compile('mail\sexchanger\s=\s(\d+)\s(.*)\.')
-
-def query_mx(host):
- mx = []
- addr = {}
- fout, fin = popen2.popen2('which nslookup')
- cmd = fout.readline().strip()
- if cmd <> '':
- fout, fin = popen2.popen2('%s -query=mx %s' % (cmd, host))
- line = fout.readline()
- while line <> '':
- m = mx_re.search(line.lower())
- if m:
- mx.append((eval(m.group(1)), m.group(2)))
- line = fout.readline()
-
- if mx:
- mx.sort()
- return mx
-
-#
-# if __name__ == "__main__":
-# print query_mx('google.com')
View
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+echo -e "\nRunning: (pep8 --show-source --show-pep8 --select=errors --testsuite=.)\n\n"
+pep8 --show-source --show-pep8 --select=errors --testsuite=./
+echo -e "\n\n"
View
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-python setup.py sdist
-python setup.py register
-python setup.py sdist upload
-
-
View
@@ -0,0 +1 @@
+
Oops, something went wrong.

0 comments on commit d61d8c5

Please sign in to comment.