def updateFiles(dirs, map_old2new, counter,
                suffixes,
                regex_restrict=None,
                dry_run=False):

    if regex_restrict:
        rx = re.compile(regex_restrict)
    else:
        rx = None

    for d in dirs:
        for root, dirs, files in os.walk(d):
            for f in files:
                _, ext = os.path.splitext(f)
                if rx and not rx.search(f):
                    continue
                if ext not in suffixes:
                    continue

                counter.files_examined += 1
                fn = os.path.join(root, f)
                with IOTools.openFile(fn, "r") as inf:
                    old_data = inf.read()

                changed = False
                for old_name, new_name in map_old2new.items():
                    # only replace at word boundaries
                    old_name += """(['`\s"=])"""
                    new_name += r"\1"
                    new_data = re.sub(old_name, new_name, old_data)
                    if old_data != new_data:
                        changed = True
                        E.info("changed: %s : %s to %s" %
                               (fn, old_name, new_name))
                    old_data = new_data

                if changed:
                    counter.files_changed += 1

                    if not dry_run:
                        with IOTools.openFile(fn, "w") as outf:
                            outf.write(new_data)
iterate through all files in dirs and
dataset/ETHPy150Open CGATOxford/cgat/refactor/cgat_refactor.py/updateFiles