def execute(cls, options): user_map = {} import_options = {} for s in options.import_opts: k, v = s.split('=', 1) if v == 'false': v = False import_options[k] = v if options.user_map_file: f = open(options.user_map_file) try: user_map = json.load(f) if type(user_map) is not type({}): raise ValueError for k, v in user_map.iteritems(): if not isinstance(k, basestring) or not isinstance( v, basestring): raise ValueError except ValueError: raise '--user-map should specify JSON file with format {"original_user": "******", ...}' finally: f.close() import_options['user_map'] = user_map cli = AlluraImportApiClient(options.base_url, options.api_key, options.secret_key, options.verbose) doc_txt = open(options.file_data).read() import_tracker(cli, options.project, options.tracker, import_options, doc_txt, validate=options.validate, verbose=options.verbose, cont=options.cont)
def load_data(doc_file_name=None, optparser=None, options=None): import_options = {} for s in options.import_opts: k, v = s.split('=', 1) if v == 'false': v = False import_options[k] = v user_map = {} if options.user_map_file: f = open(options.user_map_file) try: user_map = json.load(f) if type(user_map) is not type({}): raise ValueError for k, v in user_map.iteritems(): print k, v if not isinstance(k, basestring) or not isinstance(v, basestring): raise ValueError except ValueError: optparser.error('--user-map should specify JSON file with format {"original_user": "******", ...}') finally: f.close() import_options['user_map'] = user_map cli = AlluraImportApiClient(options.base_url, options.api_key, options.secret_key, options.verbose) doc_txt = open(doc_file_name).read() if options.wiki: import_wiki(cli, options.project, options.wiki, options, doc_txt)
def main(): optparser, options, args = parse_options() import_options = {} for s in options.import_opts: k, v = s.split('=', 1) if v == 'false': v = False import_options[k] = v user_map = {} if options.user_map_file: f = open(options.user_map_file) try: user_map = json.load(f) if type(user_map) is not type({}): raise ValueError for k, v in user_map.iteritems(): print k, v if not isinstance(k, basestring) or not isinstance( v, basestring): raise ValueError except ValueError: optparser.error( '--user-map should specify JSON file with format {"original_user": "******", ...}' ) finally: f.close() import_options['user_map'] = user_map cli = AlluraImportApiClient(options.base_url, options.api_key, options.secret_key, options.verbose) doc_txt = open(args[0]).read() # import the tracker (if any) if options.tracker: import_tracker(cli, options.project, options.tracker, import_options, options, doc_txt, validate=options.validate, verbose=options.verbose) elif options.forum: import_forum(cli, options.project, options.forum, user_map, doc_txt, validate=options.validate) elif options.wiki: import_wiki(cli, options.project, options.wiki, options, doc_txt)
def main(): optparser, options, args = parse_options() import_options = {} for s in options.import_opts: k, v = s.split('=', 1) if v == 'false': v = False import_options[k] = v user_map = {} if options.user_map_file: f = open(options.user_map_file) try: user_map = json.load(f) if not isinstance(user_map, type({})): raise ValueError for k, v in six.iteritems(user_map): print(k, v) if not isinstance(k, six.string_types) or not isinstance( v, six.string_types): raise ValueError except ValueError: optparser.error( '--user-map should specify JSON file with format {"original_user": "******", ...}' ) finally: f.close() import_options['user_map'] = user_map cli = AlluraImportApiClient(options.base_url, options.token, options.verbose) doc_txt = open(args[0]).read() if options.forum: import_forum(cli, options.project, options.forum, user_map, doc_txt, validate=options.validate, neighborhood=options.neighborhood) elif options.wiki: import_wiki(cli, options.project, options.wiki, options, doc_txt)