Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
eb5ba067
Kaydet (Commit)
eb5ba067
authored
Haz 10, 2014
tarafından
Terry Jan Reedy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge with 3.4
üst
fa66e01f
4762382d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
20 deletions
+29
-20
GrepDialog.py
Lib/idlelib/GrepDialog.py
+29
-20
No files found.
Lib/idlelib/GrepDialog.py
Dosyayı görüntüle @
eb5ba067
import
os
import
fnmatch
import
re
# for htest
import
sys
from
tkinter
import
*
from
tkinter
import
StringVar
,
BooleanVar
,
Checkbutton
# for GrepDialog
from
tkinter
import
Tk
,
Text
,
Button
,
SEL
,
END
# for htest
from
idlelib
import
SearchEngine
import
itertools
from
idlelib.SearchDialogBase
import
SearchDialogBase
# Importing OutputWindow fails due to import loop
# EditorWindow -> GrepDialop -> OutputWindow -> EditorWindow
def
grep
(
text
,
io
=
None
,
flist
=
None
):
root
=
text
.
_root
()
...
...
@@ -63,7 +68,7 @@ class GrepDialog(SearchDialogBase):
if
not
path
:
self
.
top
.
bell
()
return
from
idlelib.OutputWindow
import
OutputWindow
from
idlelib.OutputWindow
import
OutputWindow
# leave here!
save
=
sys
.
stdout
try
:
sys
.
stdout
=
OutputWindow
(
self
.
flist
)
...
...
@@ -79,21 +84,26 @@ class GrepDialog(SearchDialogBase):
pat
=
self
.
engine
.
getpat
()
print
(
"Searching
%
r in
%
s ..."
%
(
pat
,
path
))
hits
=
0
for
fn
in
list
:
try
:
with
open
(
fn
,
errors
=
'replace'
)
as
f
:
for
lineno
,
line
in
enumerate
(
f
,
1
):
if
line
[
-
1
:]
==
'
\n
'
:
line
=
line
[:
-
1
]
if
prog
.
search
(
line
):
sys
.
stdout
.
write
(
"
%
s:
%
s:
%
s
\n
"
%
(
fn
,
lineno
,
line
))
hits
+=
1
except
OSError
as
msg
:
print
(
msg
)
print
((
"Hits found:
%
s
\n
"
"(Hint: right-click to open locations.)"
%
hits
)
if
hits
else
"No hits."
)
try
:
for
fn
in
list
:
try
:
with
open
(
fn
,
errors
=
'replace'
)
as
f
:
for
lineno
,
line
in
enumerate
(
f
,
1
):
if
line
[
-
1
:]
==
'
\n
'
:
line
=
line
[:
-
1
]
if
prog
.
search
(
line
):
sys
.
stdout
.
write
(
"
%
s:
%
s:
%
s
\n
"
%
(
fn
,
lineno
,
line
))
hits
+=
1
except
OSError
as
msg
:
print
(
msg
)
print
((
"Hits found:
%
s
\n
"
"(Hint: right-click to open locations.)"
%
hits
)
if
hits
else
"No hits."
)
except
AttributeError
:
# Tk window has been closed, OutputWindow.text = None,
# so in OW.write, OW.text.insert fails.
pass
def
findfiles
(
self
,
dir
,
base
,
rec
):
try
:
...
...
@@ -120,7 +130,8 @@ class GrepDialog(SearchDialogBase):
self
.
top
.
grab_release
()
self
.
top
.
withdraw
()
def
_grep_dialog
(
parent
):
def
_grep_dialog
(
parent
):
# for htest
from
idlelib.PyShell
import
PyShellFileList
root
=
Tk
()
root
.
title
(
"Test GrepDialog"
)
...
...
@@ -141,8 +152,6 @@ def _grep_dialog(parent):
root
.
mainloop
()
if
__name__
==
"__main__"
:
# A human test is a bit tricky since EditorWindow() imports this module.
# Hence Idle must be restarted after editing this file for a live test.
import
unittest
unittest
.
main
(
'idlelib.idle_test.test_grep'
,
verbosity
=
2
,
exit
=
False
)
...
...
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