"""Tool functions for GNUViech administration tool (c) 2004 Jan Dittberner """ 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)