equal
deleted
inserted
replaced
9 """ |
9 """ |
10 |
10 |
11 from VirtualMailManager import check_domainname, check_localpart |
11 from VirtualMailManager import check_domainname, check_localpart |
12 from VirtualMailManager.constants.ERROR import \ |
12 from VirtualMailManager.constants.ERROR import \ |
13 DOMAIN_NO_NAME, INVALID_ADDRESS, LOCALPART_INVALID |
13 DOMAIN_NO_NAME, INVALID_ADDRESS, LOCALPART_INVALID |
14 from VirtualMailManager.Exceptions import VMMEmailAddressException as VMMEAE |
14 from VirtualMailManager.errors import EmailAddressError as EAErr |
15 |
15 |
16 |
16 |
17 _ = lambda msg: msg |
17 _ = lambda msg: msg |
18 |
18 |
19 |
19 |
61 address. If so, it will assign the corresponding values to the |
61 address. If so, it will assign the corresponding values to the |
62 attributes `_localpart` and `_domainname`.""" |
62 attributes `_localpart` and `_domainname`.""" |
63 parts = address.split('@') |
63 parts = address.split('@') |
64 p_len = len(parts) |
64 p_len = len(parts) |
65 if p_len < 2: |
65 if p_len < 2: |
66 raise VMMEAE(_(u"Missing the '@' sign in address %r") % address, |
66 raise EAErr(_(u"Missing the '@' sign in address %r") % address, |
67 INVALID_ADDRESS) |
67 INVALID_ADDRESS) |
68 elif p_len > 2: |
68 elif p_len > 2: |
69 raise VMMEAE(_(u"Too many '@' signs in address %r") % address, |
69 raise EAErr(_(u"Too many '@' signs in address %r") % address, |
70 INVALID_ADDRESS) |
70 INVALID_ADDRESS) |
71 if not parts[0]: |
71 if not parts[0]: |
72 raise VMMEAE(_(u"Missing local-part in address %r") % address, |
72 raise EAErr(_(u'Missing local-part in address %r') % address, |
73 LOCALPART_INVALID) |
73 LOCALPART_INVALID) |
74 if not parts[1]: |
74 if not parts[1]: |
75 raise VMMEAE(_(u"Missing domain name in address %r") % address, |
75 raise EAErr(_(u'Missing domain name in address %r') % address, |
76 DOMAIN_NO_NAME) |
76 DOMAIN_NO_NAME) |
77 self._localpart = check_localpart(parts[0]) |
77 self._localpart = check_localpart(parts[0]) |
78 self._domainname = check_domainname(parts[1]) |
78 self._domainname = check_domainname(parts[1]) |
79 |
79 |
80 |
80 |
81 del _ |
81 del _ |