-
-
Save jgarte/7b65f6a020b39a4eb4bd4419e4f4d2d5 to your computer and use it in GitHub Desktop.
python mover of things
This file contains hidden or 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