def METHOD_NAME():
    parser = argparse.ArgumentParser(description='Upgrade EasyBuild toolchain.')
    parser.add_argument('--debug',
                        type=bool, default=False,
                        help="Print verbose info.")
    parser.add_argument('--toolchain-prefix',
                        required=False,
                        help="Toolchain prefix for validation.")
    parser.add_argument('--version',
                        required=True,
                        help="New toolchain version to use.")
    parser.add_argument('--metadata',
                        type=argparse.FileType('r'), required=False,
                        help="Target metadata.")
    parser.add_argument('--filenames',
                        nargs='+', required=True,
                        help="Files to process.")
    args = vars(parser.parse_args())
    if args['debug']:
        print(args)
        print(f"New toolchain is set {args['toolchain_prefix']}*-{args['version']}")
    if args['metadata']:
        modules = parse_metadata(args['metadata'])
        if args['debug']:
            print('Metadata:\n', modules)
    successful = 0
    for filename in args['filenames']:
        try:
            print(f"Processing EasyBuild config {filename} ...")
            if args['debug']:
                print("The new config will be placed in original directory.")
            with open(filename, "r") as originalconfig:
                ec = originalconfig.read()  # contains newlines.
            if args['debug']:
                print("---- The original config was:\n", ec)
            toolchain, version = parse_tc(ec, args['debug'])
            if args['toolchain_prefix'] and not toolchain.startswith(args['toolchain_prefix']):
                raise RuntimeError(f"Invalid toolchain prefix in {filename}")
            newecfilename = filename.replace(f"{toolchain}-{version}",
                                            f"{toolchain}-{args['version']}")
            if args['debug']:
                print("New config file name will be: ", newecfilename)
            newec = re.sub(tc_pattern,
                        f"toolchain = {{'name': '{toolchain}', 'version': '{args['version']}'}}",
                        ec)
            if args['metadata']:
                # find all external dependencies
                deps = re.findall(dep_pattern, newec)
                if deps is not None:
                    if args['debug']:
                        print("External Modules:\n", deps)
                    for dep in deps:
                        mod = dep.split('/')[0]
                        if mod in modules.keys():
                            ver = modules[mod]
                            if ver is not None:
                                assert len(dep.split('/')) > 1,  f"Error: Undefined version in external dependency '{dep}'"
                                depver = dep.split('/')[1]
                                majver = depver.split('.')[0]
                                # get latest matching version
                                ver = ver[majver] if majver in ver.keys() else ver.values()[-1]
                                mod = f"{mod}/{ver}"
                            if args['debug']:
                                print(f"Replacing '{dep}' by '{mod}'")
                                print(dep_regex(dep))
                            newec = re.sub(dep_regex(dep), f"('{mod}', EXTERNAL_MODULE)", newec)
            if args['debug']:
                print("---- New config will be:\n", newec)
            ## Check new toolchain
            _, version = parse_tc(newec, args['debug'])
            if version != args['version']:
                raise RuntimeError("Error: Failed to replace toolchain version.")
            with open(newecfilename, "w") as newconfig:
                newconfig.write(newec)  # contains newlines.
            print("Finished writing new config:", newecfilename)
            successful += 1
        except Exception as ex:
            print(ex)
    print(f"Upgrade succeeded for {successful} out of {len(args['filenames'])} files")
    return len(args['filenames']) - successful