rope
rope copied to clipboard
Restructuring fails with if statement
I'm trying to substitute a variable with restructuring but it failed with following error. environment : visual studio, pypy2 5.9.0, rope 0.10.7
[dddd.py]
project = Project(os.path.join(defs.IO_Dir, 'test1'))
mod1 = project.get_resource('mod1.py')
from rope.refactor import restructure
#pattern = '${pow_func}(${param1}, ${param2})'
#goal = '${param1} ** ${param2}'
#args = {'pow_func': 'name=mod1.pow'}
pattern = '${Debug}'
goal = 'True'
args = {'Debug': 'name=mod1.lalala'}
restructuring = restructure.Restructure(project, pattern, goal, args)
k = restructuring.get_changes(resources=[mod1] )
project.do(k)
[mod1.py] Try 1
lalala = 44453
if(lalala == False):
lalala = 409024
pass
[mod1.py] Try 2
lalala = 44453
if(lalala == False):
lalala = 409024
pass
elif(534 == lalala):
pass
[mod1.py] Try 3
lalala = 44453
if(lalala == False):
lalala = 409024
pass
elif(534 == lalala):
pass
else:
lalala = 55223
pass
Try 1 succeeded but try 2 and 3 fails with following error each:
Try 2 : rope.refactor.patchedast.MismatchedTokenError: Token
Thank you for reporting and including good tests cases to reproduce it.