I have worked all morning on a script that *safely* replaces::
g.choose(test,a,b)
with::
a if test else b
**Warning**: this is still experimental code. I have tried it with the
"replace" switch on, so no actual replacements get made.
This is a tricky task. One can't just use s.find to look for g.choose.
Ditto for discovering the test, a and b args. Instead, the script must
carefully parse Python strings, comments and parenthesized expressions.
This kind of text munging is common. Perhaps its time to build a general
purpose Python scanner class, or maybe it's time to use third-party tools.
There are parallels with Rope's refactoring library. In any event, there
is considerable Leo-centric code required, especially the undo code.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.