@@ -0,0 +1,1704 @@
+#!/bin/env python3%0A%0Aimport os%0Aimport re%0Aimport sys%0A%0Aif len(sys.argv) %3C 2 :#or sys.argv%5B1%5D == %22--help%22:%0A    print(%22rename_code.py %3Csource_code_directory%3E%22)%0A    print(%22Update python code to new style.%22)%0A    sys.exit(0)%0A%0Aold_names = set()%0Aclass_names = set()%0Afor (dir, dirs, files) in os.walk(sys.argv%5B1%5D):%0A    if dir == %22.git%22:%0A        continue%0A    for file in files:%0A        if not file.endswith(%22.py%22):%0A            continue%0A        path = os.path.join(dir, file)%0A        print(%22-----%22, path)%0A        with open(path) as f:%0A            data = f.read()%0A        for i in re.finditer(r%22%5Cbdef%5Cs+(%5Cw+)%22, data):%0A            name = i.group(1)%0A            if re.search(r%22%5BA-Z%5D%22, name):%0A                print(%22:%22, name)%0A                old_names.add(name)%0A        for i in re.finditer(r%22%5Cbclass%5Cs+(%5Cw+)%22, data):%0A            name = i.group(1)%0A            class_names.add(name)%0A#print(%22old_names:%22, old_names)%0A#print(%22class_names:%22, class_names)%0Afor i in class_names:%0A    if i in old_names:%0A        print(i, %22is also a class name%22)%0A        old_names.remove(i)%0A#print(%22old_names:%22, old_names)%0Afind_old_name = re.compile(r%22(%5Cb%22+r%22%5Cb%7C%5Cb%22.join(old_names)+r%22)%5Cb%22)%0Afor (dir, dirs, files) in os.walk(sys.argv%5B1%5D):%0A    if dir == %22.git%22:%0A        continue%0A    for file in files:%0A        if not file.endswith(%22.py%22):%0A            continue%0A        path = os.path.join(dir, file)%0A        print(%22-----%22, path)%0A        with open(path, %22r+%22) as f:%0A            data = find_old_name.sub(%0A                    lambda x: re.sub(%0A                        %22(%5BA-Z%5D)%22,%0A                        lambda n: %22_%22+n.group(1).lower(),%0A                        x.group(1)),%0A                    f.read())%0A            f.seek(0)%0A            f.write(data)%0A%0A%0A

Add tool to update method names.