5543.7.3
by Tim Penhey
New revisions now check to see if we know the author. |
1 |
#!/usr/bin/python2.4
|
2 |
# Copyright 2008 Canonical Ltd. All rights reserved.
|
|
5543.7.4
by Tim Penhey
All done. |
3 |
# Disable pylint complaining about relative import of _pythonpath
|
4 |
# pylint: disable-msg=W0403
|
|
5543.7.3
by Tim Penhey
New revisions now check to see if we know the author. |
5 |
|
6 |
"""Try to link RevionAuthors to Launchpad Person entries.
|
|
7 |
||
8 |
Iterate through the RevisionAuthors and extract their email address.
|
|
9 |
Then use that email address to link to a Person.
|
|
10 |
"""
|
|
11 |
||
12 |
import _pythonpath |
|
13 |
||
14 |
import email.Utils |
|
15 |
import sys |
|
16 |
||
17 |
from canonical.launchpad.scripts import execute_zcml_for_scripts |
|
18 |
from canonical.lp import initZopeless |
|
19 |
||
20 |
from canonical.launchpad.database.revision import RevisionAuthor |
|
21 |
||
22 |
def main(argv): |
|
23 |
execute_zcml_for_scripts() |
|
24 |
ztm = initZopeless() |
|
25 |
try: |
|
5543.7.4
by Tim Penhey
All done. |
26 |
total = RevisionAuthor.select().count() |
27 |
for number, author in enumerate(RevisionAuthor.select()): |
|
5543.7.3
by Tim Penhey
New revisions now check to see if we know the author. |
28 |
if author.email is None: |
29 |
email_address = email.Utils.parseaddr(author.name)[1] |
|
30 |
# If there is no @, then it isn't a real email address.
|
|
31 |
if '@' in email_address: |
|
32 |
author.email = email_address |
|
33 |
if author.linkToLaunchpadPerson(): |
|
5743.2.4
by Tim Penhey
Page tests now pass. |
34 |
print "%s linked to %s" % ( |
35 |
author.name.encode('ascii', 'replace'), |
|
36 |
author.person.name) |
|
5543.7.3
by Tim Penhey
New revisions now check to see if we know the author. |
37 |
ztm.commit() |
38 |
finally: |
|
39 |
ztm.abort() |
|
40 |
||
41 |
||
42 |
if __name__ == '__main__': |
|
43 |
main(sys.argv) |