OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import collections | 5 import collections |
6 import email.utils | 6 import email.utils |
7 | 7 |
8 | 8 |
9 def lazy_property(func): | 9 def lazy_property(func): |
10 """A decorator for lazy properties.""" | 10 """A decorator for lazy properties.""" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 def get_emails(string): | 79 def get_emails(string): |
80 """Normalizes a string containing a list of email recepients. | 80 """Normalizes a string containing a list of email recepients. |
81 | 81 |
82 Takes a string in the format present in mail headers and returns a list of | 82 Takes a string in the format present in mail headers and returns a list of |
83 email addresses. For example, the input | 83 email addresses. For example, the input |
84 'test@example.com, committers <committers@chromium.org> | 84 'test@example.com, committers <committers@chromium.org> |
85 will produce this return value: | 85 will produce this return value: |
86 [ 'test@example.com', 'committers@chromium.org' ] | 86 [ 'test@example.com', 'committers@chromium.org' ] |
87 """ | 87 """ |
88 return [entry[1] for entry in email.utils.getaddresses([string])] | 88 return [entry[1] for entry in email.utils.getaddresses([string])] |
| 89 |
| 90 |
| 91 def canonicalize_email(address): |
| 92 """Takes an email address and returns its canonicalized form.""" |
| 93 emails = get_emails(address) |
| 94 assert len(emails) == 1 |
| 95 return emails[0] |
OLD | NEW |