diff options
author | Guido van Rossum <guido@python.org> | 2002-07-24 19:13:08 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-07-24 19:13:08 (GMT) |
commit | f8c8cf8a9d8b9136571b65e82f95e136fd0374e8 (patch) | |
tree | 4382e545cc08602cb0a1db5d2f66aecf6cff906d | |
parent | 403e351dfcb406ab78204be1c56aeae1ddde7d85 (diff) | |
download | cpython-f8c8cf8a9d8b9136571b65e82f95e136fd0374e8.zip cpython-f8c8cf8a9d8b9136571b65e82f95e136fd0374e8.tar.gz cpython-f8c8cf8a9d8b9136571b65e82f95e136fd0374e8.tar.bz2 |
Get rid of _expand() altogether - the match object supports m.expand().
-rw-r--r-- | Tools/idle/ReplaceDialog.py | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/Tools/idle/ReplaceDialog.py b/Tools/idle/ReplaceDialog.py index 7d5de69..3d71703 100644 --- a/Tools/idle/ReplaceDialog.py +++ b/Tools/idle/ReplaceDialog.py @@ -6,7 +6,6 @@ from Tkinter import * import tkMessageBox import SearchEngine from SearchDialogBase import SearchDialogBase -import sre_parse def replace(text): root = text._root() @@ -91,7 +90,7 @@ class ReplaceDialog(SearchDialogBase): line, m = res chars = text.get("%d.0" % line, "%d.0" % (line+1)) orig = m.group() - new = self._expand(m, repl) + new = m.expand(repl) i, j = m.span() first = "%d.%d" % (line, i) last = "%d.%d" % (line, j) @@ -143,7 +142,7 @@ class ReplaceDialog(SearchDialogBase): m = prog.match(chars, col) if not prog: return False - new = self._expand(m, self.replvar.get()) + new = m.expand(self.replvar.get()) text.mark_set("insert", first) text.undo_block_start() if m.group(): @@ -155,14 +154,6 @@ class ReplaceDialog(SearchDialogBase): self.ok = 0 return True - def _expand(self, m, template): - # XXX This code depends on internals of the regular expression - # engine! There's no standard API to do a substitution when you - # have already found the match. One should be added. - # XXX This parses the template over and over... - ptemplate = sre_parse.parse_template(template, m.re) - return sre_parse.expand_template(ptemplate, m) - def show_hit(self, first, last): text = self.text text.mark_set("insert", first) |