2004-12-26 00:09:19 +01:00
|
|
|
"""Tool functions for GNUViech administration tool
|
|
|
|
|
|
|
|
(c) 2004 Jan Dittberner <jan@gnuviech.info>
|
|
|
|
"""
|
|
|
|
|
2004-12-26 16:50:53 +01:00
|
|
|
import random, re
|
2004-12-26 00:09:19 +01:00
|
|
|
from gnuviech import GNVPrefs
|
|
|
|
|
|
|
|
def generatePassword():
|
|
|
|
return "".join([chr(char) for char in
|
2004-12-26 16:50:53 +01:00
|
|
|
random.sample(GNVPrefs.PWDCHARS,
|
|
|
|
random.randint(GNVPrefs.PWDMINLENGTH,
|
|
|
|
GNVPrefs.PWDMAXLENGTH))])
|
2004-12-26 00:09:19 +01:00
|
|
|
|
2004-12-26 16:50:53 +01:00
|
|
|
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)
|