VirtualMailManager/emailaddress.py
branchv0.6.x
changeset 417 8209da83e256
parent 367 a6ad9895989d
child 427 8e41e77b84e6
equal deleted inserted replaced
416:f32b323fd347 417:8209da83e256
    66         address.  If so, it will assign the corresponding values to the
    66         address.  If so, it will assign the corresponding values to the
    67         attributes `_localpart` and `_domainname`."""
    67         attributes `_localpart` and `_domainname`."""
    68         parts = address.split('@')
    68         parts = address.split('@')
    69         p_len = len(parts)
    69         p_len = len(parts)
    70         if p_len < 2:
    70         if p_len < 2:
    71             raise EAErr(_(u"Missing the '@' sign in address '%s'") % address,
    71             raise EAErr(_(u"Missing the '@' sign in address: '%s'") % address,
    72                         INVALID_ADDRESS)
    72                         INVALID_ADDRESS)
    73         elif p_len > 2:
    73         elif p_len > 2:
    74             raise EAErr(_(u"Too many '@' signs in address '%s'") % address,
    74             raise EAErr(_(u"Too many '@' signs in address: '%s'") % address,
    75                         INVALID_ADDRESS)
    75                         INVALID_ADDRESS)
    76         if not parts[0]:
    76         if not parts[0]:
    77             raise EAErr(_(u"Missing local-part in address '%s'") % address,
    77             raise EAErr(_(u"Missing local-part in address: '%s'") % address,
    78                         LOCALPART_INVALID)
    78                         LOCALPART_INVALID)
    79         if not parts[1]:
    79         if not parts[1]:
    80             raise EAErr(_(u"Missing domain name in address '%s'") % address,
    80             raise EAErr(_(u"Missing domain name in address: '%s'") % address,
    81                         DOMAIN_NO_NAME)
    81                         DOMAIN_NO_NAME)
    82         self._localpart = check_localpart(parts[0])
    82         self._localpart = check_localpart(parts[0])
    83         self._domainname = check_domainname(parts[1])
    83         self._domainname = check_domainname(parts[1])
    84 
    84 
    85 
    85 
   119 
   119 
   120     Throws a `EmailAddressError` if the local-part is too long or contains
   120     Throws a `EmailAddressError` if the local-part is too long or contains
   121     invalid characters.
   121     invalid characters.
   122     """
   122     """
   123     if len(localpart) > 64:
   123     if len(localpart) > 64:
   124         raise EAErr(_(u"The local-part '%s' is too long") % localpart,
   124         raise EAErr(_(u"The local-part '%s' is too long.") % localpart,
   125                     LOCALPART_TOO_LONG)
   125                     LOCALPART_TOO_LONG)
   126     invalid_chars = set(RE_LOCALPART.findall(localpart))
   126     invalid_chars = set(RE_LOCALPART.findall(localpart))
   127     if invalid_chars:
   127     if invalid_chars:
   128         i_chars = u''.join((u'"%s" ' % c for c in invalid_chars))
   128         i_chars = u''.join((u'"%s" ' % c for c in invalid_chars))
   129         raise EAErr(_(u"The local-part '%(l_part)s' contains invalid "
   129         raise EAErr(_(u"The local-part '%(l_part)s' contains invalid "