1
0
Fork 0
gnuviechadmin-historic/backend/gnuviech/tools.py
Jan Dittberner b9ec217d1e - add logging to the test class
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@86 a67ec6bc-e5d5-0310-a910-815c51eb3124
2004-12-26 15:50:53 +00:00

21 lines
703 B
Python

"""Tool functions for GNUViech administration tool
(c) 2004 Jan Dittberner <jan@gnuviech.info>
"""
import random, re
from gnuviech import GNVPrefs
def generatePassword():
return "".join([chr(char) for char in
random.sample(GNVPrefs.PWDCHARS,
random.randint(GNVPrefs.PWDMINLENGTH,
GNVPrefs.PWDMAXLENGTH))])
def checkEmail(email):
"""Returns a match object if the given email address is syntactically
correct otherwise it returns None"""
# regex for email check
p = re.compile(r'^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9\-]+(\.|[a-zA-Z0-9\-]+)*\.[a-z]{2,5})$')
return p.search(email)