コード例 #1
0
ファイル: mail.py プロジェクト: jokey2k/pyClanSphere
def split_email(s):
    """Split a mail address:

    >>> split_email("John Doe")
    ('John Doe', None)
    >>> split_email("John Doe <*****@*****.**>")
    ('John Doe', '*****@*****.**')
    >>> split_email("*****@*****.**")
    (None, '*****@*****.**')
    """
    p1, p2 = _mail_split_re.search(s).groups()
    if p2:
        return p1, p2
    elif check(is_valid_email, p1):
        return None, p1
    return p1, None
コード例 #2
0
ファイル: __init__.py プロジェクト: jokey2k/pyClanSphere
 def test_admin_account(self, request):
     """Check if the admin mail is valid and the passwords match."""
     _ = request.translations.gettext
     errors = []
     if not request.values.get('admin_username'):
         errors.append(_('You have to provide a username.'))
     email = request.values.get('admin_email')
     if not email:
         errors.append(_('You have to enter a mail address.'))
     elif not check(is_valid_email, email):
         errors.append(_('The mail address is not valid.'))
     password = request.values.get('admin_password')
     if not password:
         errors.append(_('You have to enter a password.'))
     if password != request.values.get('admin_password2'):
         errors.append(_('The two passwords do not match.'))
     if errors:
         return {'error': errors[0]}