VirtualMailManager/EmailAddress.py
changeset 133 2d5c4745efec
parent 116 949c5db6447a
child 138 617f27715b01
equal deleted inserted replaced
132:fa22bd13b4d1 133:2d5c4745efec
    41 
    41 
    42     def __chkAddress(self, address):
    42     def __chkAddress(self, address):
    43         try:
    43         try:
    44             localpart, domain = address.split('@')
    44             localpart, domain = address.split('@')
    45         except ValueError:
    45         except ValueError:
    46             raise VMMEAE(_(u"Missing '@' sign in e-mail address »%s«.") %
    46             raise VMMEAE(_(u"Missing '@' sign in e-mail address “%s”.") %
    47                 address, ERR.INVALID_ADDRESS)
    47                 address, ERR.INVALID_ADDRESS)
    48         except AttributeError:
    48         except AttributeError:
    49             raise VMMEAE(_(u"»%s« looks not like an e-mail address.") %
    49             raise VMMEAE(_(u"“%s” looks not like an e-mail address.") %
    50                 address, ERR.INVALID_ADDRESS)
    50                 address, ERR.INVALID_ADDRESS)
    51         if len(domain) > 0:
    51         if len(domain) > 0:
    52             domain = VMM.VirtualMailManager.chkDomainname(domain)
    52             domain = VMM.VirtualMailManager.chkDomainname(domain)
    53         else:
    53         else:
    54             raise VMMEAE(_(u"Missing domain name after »%s@«.") %
    54             raise VMMEAE(_(u"Missing domain name after “%s@”.") %
    55                     localpart, ERR.DOMAIN_NO_NAME)
    55                     localpart, ERR.DOMAIN_NO_NAME)
    56         localpart = self.__chkLocalpart(localpart)
    56         localpart = self.__chkLocalpart(localpart)
    57         self._localpart, self._domainname = localpart, domain
    57         self._localpart, self._domainname = localpart, domain
    58 
    58 
    59     def __chkLocalpart(self, localpart):
    59     def __chkLocalpart(self, localpart):
    64         """
    64         """
    65         if len(localpart) < 1:
    65         if len(localpart) < 1:
    66             raise VMMEAE(_(u'No localpart specified.'),
    66             raise VMMEAE(_(u'No localpart specified.'),
    67                 ERR.LOCALPART_INVALID)
    67                 ERR.LOCALPART_INVALID)
    68         if len(localpart) > 64:
    68         if len(localpart) > 64:
    69             raise VMMEAE(_(u'The local part »%s« is too long') %
    69             raise VMMEAE(_(u'The local part “%s” is too long') %
    70                 localpart, ERR.LOCALPART_TOO_LONG)
    70                 localpart, ERR.LOCALPART_TOO_LONG)
    71         ic = set(re.findall(RE_LOCALPART, localpart))
    71         ic = set(re.findall(RE_LOCALPART, localpart))
    72         if len(ic):
    72         if len(ic):
    73             ichrs = ''
    73             ichrs = ''
    74             for c in ic:
    74             for c in ic:
    75                 ichrs += u"»%s« " % c
    75                 ichrs += u"“%s” " % c
    76             raise VMMEAE(_(u"The local part »%(lpart)s« contains invalid\
    76             raise VMMEAE(_(u"The local part “%(lpart)s” contains invalid\
    77  characters: %(ichrs)s") % {'lpart': localpart, 'ichrs': ichrs},
    77  characters: %(ichrs)s") % {'lpart': localpart, 'ichrs': ichrs},
    78                 ERR.LOCALPART_INVALID)
    78                 ERR.LOCALPART_INVALID)
    79         return localpart
    79         return localpart
    80 
    80