Skip to content

Instantly share code, notes, and snippets.

Created December 2, 2013 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7761145 to your computer and use it in GitHub Desktop.
Save anonymous/7761145 to your computer and use it in GitHub Desktop.
attachment for the BitBucket issue #15
#!/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