Created
July 25, 2019 23:33
-
-
Save cowlicks/7bbd54267c7e18a35e023a78a3d55a25 to your computer and use it in GitHub Desktop.
python mover of things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def move_thing(src_mod, dest_mod, find_str): | |
import os | |
import rope.base.project | |
from rope.base import libutils | |
from rope.refactor import move | |
project = rope.base.project.Project(os.getcwd()) | |
origin = libutils.path_to_resource(project, src_mod) | |
destination = libutils.path_to_resource(project, dest_mod) | |
offset = origin.read().index(find_str) | |
move_object = move.create_move(project, origin, offset) | |
changes = move_object.get_changes(destination) | |
project.do(changes) | |
project.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment