Switch to unified view

a/migrate-3rdparty/allura_import.py b/migrate-3rdparty/allura_import.py
...
...
2
import urllib
2
import urllib
3
import urllib2
3
import urllib2
4
import urlparse
4
import urlparse
5
import hmac
5
import hmac
6
import hashlib
6
import hashlib
7
import json
7
from optparse import OptionParser
8
from optparse import OptionParser
8
from pprint import pprint
9
from pprint import pprint
9
from datetime import datetime
10
from datetime import datetime
10
11
11
12
...
...
17
    optparser.add_option('-s', '--secret-key', dest='secret_key', help='Secret key')
18
    optparser.add_option('-s', '--secret-key', dest='secret_key', help='Secret key')
18
    optparser.add_option('-p', '--project', dest='project', help='Project to import to')
19
    optparser.add_option('-p', '--project', dest='project', help='Project to import to')
19
    optparser.add_option('-t', '--tracker', dest='tracker', help='Tracker to import to')
20
    optparser.add_option('-t', '--tracker', dest='tracker', help='Tracker to import to')
20
    optparser.add_option('-u', '--base-url', dest='base_url', default='https://sourceforge.net', help='Base Allura URL (%default)')
21
    optparser.add_option('-u', '--base-url', dest='base_url', default='https://sourceforge.net', help='Base Allura URL (%default)')
21
    optparser.add_option('-o', dest='import_opts', default=[], action='append', help='Specify import option(s)', metavar='opt=val')
22
    optparser.add_option('-o', dest='import_opts', default=[], action='append', help='Specify import option(s)', metavar='opt=val')
23
    optparser.add_option('-m', dest='user_map', default=[], action='append', help='Map users', metavar='import_user=allura_user')
22
    optparser.add_option('--validate', dest='validate', action='store_true', help='Validate import data')
24
    optparser.add_option('--validate', dest='validate', action='store_true', help='Validate import data')
23
    optparser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Verbose operation')
25
    optparser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Verbose operation')
24
    options, args = optparser.parse_args()
26
    options, args = optparser.parse_args()
25
    if len(args) != 1:
27
    if len(args) != 1:
26
        optparser.error("Wrong number of arguments")
28
        optparser.error("Wrong number of arguments")
...
...
71
    import_options = {}
73
    import_options = {}
72
    for s in options.import_opts:
74
    for s in options.import_opts:
73
        k, v = s.split('=', 1)
75
        k, v = s.split('=', 1)
74
        if v == 'false':
76
        if v == 'false':
75
            v = False
77
            v = False
76
        import_options['option_' + k] = v
78
        import_options[k] = v
77
        
79
        
80
    import_options['user_map'] = {}
81
    for s in options.user_map:
82
        k, v = s.split('=', 1)
83
        import_options['user_map'][k] = v
84
78
    cli = AlluraRestClient(options.base_url, options.api_key, options.secret_key)
85
    cli = AlluraRestClient(options.base_url, options.api_key, options.secret_key)
79
    print cli.call(url, doc=open(args[0]).read(), **import_options)
86
    print cli.call(url, doc=open(args[0]).read(), options=json.dumps(import_options))