@@ -0,0 +1,2411 @@
+import argparse%0Aimport ConfigParser%0Aimport os%0A%0Afrom qisys import ui%0Aimport qisys.parsers%0Aimport qisys.sh%0Aimport qisys.qixml%0A%0Aimport qitoolchain.toolchain%0A%0Adef get_old_toolchains():%0A    %22%22%22 Return a dict name -%3E feed from the previous config format%0A%0A    %22%22%22%0A    res = dict()%0A    cfg_path = qisys.sh.get_config_path(%22qi%22, %22toolchains.cfg%22)%0A    config = ConfigParser.ConfigParser()%0A    config.read(cfg_path)%0A    if not config.has_section(%22toolchains%22):%0A        return res%0A    tc_items = config.items(%22toolchains%22)%0A    for name, value in tc_items:%0A        res%5Bname%5D = value%0A    return res%0A%0Adef recreate_toolchains():%0A    old_toolchains = get_old_toolchains()%0A    old_names = old_toolchains.keys()%0A    old_names.sort()%0A    errors = list()%0A    for i, name in enumerate(old_names):%0A        n = len(old_names)%0A        ui.info(ui.bold, %22%5B %25d on %25d %5D%22 %25 (i+1, n), name)%0A        feed_url = old_toolchains%5Bname%5D%0A        if feed_url:%0A            toolchain = qitoolchain.toolchain.Toolchain(name)%0A            try:%0A                toolchain.update(feed_url=feed_url)%0A            except Exception as e:%0A                errors.append((name, e))%0A    if errors:%0A        ui.error(%22Could not update some toolchains%22)%0A        for name, error in errors:%0A            ui.error(%22 * %22, name, error)%0A%0Adef main():%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument(%22--no-toolchains%22, action=%22store_false%22, dest=%22toolchains%22,%0A                        help=%22Do not try to recreate the toolchains%22)%0A    parser.add_argument(%22--no-backup%22, action=%22store_false%22, dest=%22backup%22,%0A                        help=%22Do not backup build profiles%22)%0A    parser.set_defaults(toolchains=True, backup=True)%0A    qisys.parsers.worktree_parser(parser)%0A    args = parser.parse_args()%0A    worktree = qisys.parsers.get_worktree(args)%0A%0A    ui.info(ui.bold, %22Starting 3.7 migration%22)%0A    if args.toolchains:%0A        ui.info(ui.bold, %22:: Re-creating toolchains ...%22)%0A        recreate_toolchains()%0A    ui.info(ui.bold, %22:: Removing build profiles ...%22)%0A    qibuild_xml_path = os.path.join(worktree.dot_qi, %22qibuild.xml%22)%0A    tree = qisys.qixml.read(qibuild_xml_path)%0A    root = tree.getroot()%0A    profiles = tree.find(%22profiles%22)%0A    if profiles is not None:%0A        if args.backup:%0A            profiles.tag = %22profiles.back%22%0A        else:%0A            root.remove(profiles)%0A    qisys.qixml.write(root, qibuild_xml_path)%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Add a tool to ease 3.7 migration