How do I match multiple arguments in rope?

95 Views Asked by At

Note: rope is a tool for building Python refactoring into editors like Emacs and vim. It can also be used directly to execute refactors outside of an editor.

I'm trying to apply a restructuring to a function taking a variable number of arguments, e.g. going from

# math.py (before refactor)
add(1, 2, 3)
add(4, 5)

to

# math.py (after refactor)
sum(1, 2, 3)
sum(4, 5)

I'm trying to do this with a rope script:

pattern = "add(${args})"
goal = "sum(${args})"

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

However, this only matches calls to add() with one argument.

How do I generalize the pattern to match multiple arguments?

0

There are 0 best solutions below