Added emailRe to utils.net.

This commit is contained in:
Jeremy Fincher 2005-02-01 06:34:58 +00:00
parent 641c5cd634
commit 65893c8e3c
2 changed files with 9 additions and 0 deletions

View File

@ -31,8 +31,13 @@
Simple utility modules.
"""
import re
import socket
emailRe = re.compile(r"^(\w&.+-]+!)*[\w&.+-]+@"
r"(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)[a-z]{2,6}|"
r"([0-9]{1,3}\.){3}[0-9]{1,3})$", re.I)
def getSocket(host):
"""Returns a socket of the correct AF_INET type (v4 or v6) in order to
communicate with host.

View File

@ -385,6 +385,10 @@ class FileTest(SupyTestCase):
class NetTest(SupyTestCase):
def testEmailRe(self):
emailRe = utils.net.emailRe
self.failUnless(emailRe.match('jemfinch@supybot.com'))
def testIsIP(self):
isIP = utils.net.isIP
self.failIf(isIP('a.b.c'))