Created
December 2, 2013 23:35
-
-
Save anonymous/7761145 to your computer and use it in GitHub Desktop.
attachment for the BitBucket issue #15
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
#!/usr/bin/env python2 | |
import os | |
import os.path | |
import rope.base.project | |
from rope.refactor.rename import Rename | |
def main(): | |
projdir = "proj" | |
example = os.path.join(projdir, "test.py") | |
if not os.path.isdir(projdir): | |
os.mkdir(projdir) | |
if os.path.exists(example): | |
os.unlink(example) | |
f = open(example, 'w') | |
f.write('''import numpy as N | |
print type(N.ndarray) == type([]) | |
''') | |
f.close() | |
project = rope.base.project.Project(projdir) | |
mod = project.get_resource(os.path.basename(example)) | |
re = Rename(project, mod, 17) # replace 'N' | |
print "Old name: '%s'" % re.get_old_name() | |
changes = re.get_changes('np') | |
project.do(changes) | |
project.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment