Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e9ea6d00
Commit
e9ea6d00
authored
Jul 24, 2002
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of _expand() altogether - the match object supports m.expand().
parent
6272fd18
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
11 deletions
+2
-11
Tools/idle/ReplaceDialog.py
Tools/idle/ReplaceDialog.py
+2
-11
No files found.
Tools/idle/ReplaceDialog.py
View file @
e9ea6d00
...
@@ -6,7 +6,6 @@ from Tkinter import *
...
@@ -6,7 +6,6 @@ from Tkinter import *
import
tkMessageBox
import
tkMessageBox
import
SearchEngine
import
SearchEngine
from
SearchDialogBase
import
SearchDialogBase
from
SearchDialogBase
import
SearchDialogBase
import
sre_parse
def
replace
(
text
):
def
replace
(
text
):
root
=
text
.
_root
()
root
=
text
.
_root
()
...
@@ -91,7 +90,7 @@ class ReplaceDialog(SearchDialogBase):
...
@@ -91,7 +90,7 @@ class ReplaceDialog(SearchDialogBase):
line
,
m
=
res
line
,
m
=
res
chars
=
text
.
get
(
"%d.0"
%
line
,
"%d.0"
%
(
line
+
1
))
chars
=
text
.
get
(
"%d.0"
%
line
,
"%d.0"
%
(
line
+
1
))
orig
=
m
.
group
()
orig
=
m
.
group
()
new
=
self
.
_expand
(
m
,
repl
)
new
=
m
.
expand
(
repl
)
i
,
j
=
m
.
span
()
i
,
j
=
m
.
span
()
first
=
"%d.%d"
%
(
line
,
i
)
first
=
"%d.%d"
%
(
line
,
i
)
last
=
"%d.%d"
%
(
line
,
j
)
last
=
"%d.%d"
%
(
line
,
j
)
...
@@ -143,7 +142,7 @@ class ReplaceDialog(SearchDialogBase):
...
@@ -143,7 +142,7 @@ class ReplaceDialog(SearchDialogBase):
m
=
prog
.
match
(
chars
,
col
)
m
=
prog
.
match
(
chars
,
col
)
if
not
prog
:
if
not
prog
:
return
False
return
False
new
=
self
.
_expand
(
m
,
self
.
replvar
.
get
())
new
=
m
.
expand
(
self
.
replvar
.
get
())
text
.
mark_set
(
"insert"
,
first
)
text
.
mark_set
(
"insert"
,
first
)
text
.
undo_block_start
()
text
.
undo_block_start
()
if
m
.
group
():
if
m
.
group
():
...
@@ -155,14 +154,6 @@ class ReplaceDialog(SearchDialogBase):
...
@@ -155,14 +154,6 @@ class ReplaceDialog(SearchDialogBase):
self
.
ok
=
0
self
.
ok
=
0
return
True
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
):
def
show_hit
(
self
,
first
,
last
):
text
=
self
.
text
text
=
self
.
text
text
.
mark_set
(
"insert"
,
first
)
text
.
mark_set
(
"insert"
,
first
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment