3
# Copyright 2009 Canonical Ltd. This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
6
# pylint: disable-msg=W0403
13
from canonical.lp import initZopeless
14
from canonical.launchpad.scripts import (
15
execute_zcml_for_scripts, logger_options, logger as logger_from_options)
16
from lp.registry.scripts.keyringtrustanalyser import mergeClusters
20
"""Read clusters of email addresses from the file (separated by blank
21
lines), and yield them as sets."""
35
parser = optparse.OptionParser(
36
description="This script reads a list of email address clusters. "
37
"and updates the Launchpad database to match by adding email "
38
"addresses to existing accounts, merging accounts and "
39
"creating new accounts")
40
parser.add_option('-i', '--input', metavar='FILE', action='store',
41
help='Read clusters from the given file',
42
type='string', dest='input', default=None)
44
logger_options(parser, logging.WARNING)
46
options, args = parser.parse_args(argv[1:])
49
logger = logger_from_options(options)
51
if options.input is not None:
52
logger.debug('openning %s', options.input)
53
fp = open(options.input, 'r')
57
logger.info('Setting up utilities')
58
execute_zcml_for_scripts()
60
logger.info('Connecting to database')
63
mergeClusters(readClusters(fp), ztm, logger)
70
if __name__ == '__main__':
71
sys.exit(main(sys.argv))