Discussion:
Restructuring fails with if statement with MismatchedTokenError
이시인
2017-11-04 02:15:30 UTC
Permalink
I'm trying to substitute a variable with a value according to other options
but it fails with following error.



[dddd.py]

project = Project(os.path.join(defs.IO_Dir, 'test1'))

mod1 = project.get_resource('mod1.py')

pattern = '${Debug}'
goal = 'True'
args = {'Debug': 'name=mod1.lalala'}

restructuring = restructure.Restructure(project, pattern, goal, args)

k = restructuring.get_changes(resources=[mod1] ,task_handle = handle)
project.do(k)



[mod1.py] - try 1

lalala = 44453if(lalala == False):
lalala = 409024
pass


[mod1.py] - try 2

lalala = 44453

if(lalala == False):
lalala = 409024
passelif(534 == lalala):
pass


[mod1.py] - try 3

lalala = 44453

if(lalala == False):
lalala = 409024
passelif(534 == lalala):
passelse:
lalala = 55223
pass


It occurs same with default tutorial example and add pow function on start
of mod1.py.

pattern = '${pow_func}(${param1}, ${param2})'
goal = '${param1} ** ${param2}'
args = {'pow_func': 'name=mod1.pow'}


Try 1 succeeded, but try 2 and 3 fails, with error message each
"rope.refactor.patchedast.MismatchedTokenError: Token <else> at (4, 5)
cannot be matched" and "rope.refactor.patchedast.MismatchedTokenError:
Token <if> at (7, 5) cannot be matched"
--
---
You received this message because you are subscribed to the Google Groups "rope-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rope-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...