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
ec9cca77
Kaydet (Commit)
ec9cca77
authored
Haz 01, 1999
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rewritten based on TreeWidget.py
üst
1ff48ec8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
132 deletions
+67
-132
ClassBrowser.py
Tools/idle/ClassBrowser.py
+0
-0
PathBrowser.py
Tools/idle/PathBrowser.py
+67
-132
No files found.
Tools/idle/ClassBrowser.py
Dosyayı görüntüle @
ec9cca77
This diff is collapsed.
Click to expand it.
Tools/idle/PathBrowser.py
Dosyayı görüntüle @
ec9cca77
import
os
import
sys
import
imp
import
string
import
tkMessageBox
from
MultiScrolledLists
import
MultiScrolledLists
from
TreeWidget
import
TreeItem
from
ClassBrowser
import
ClassBrowser
,
ModuleBrowserTreeItem
class
PathBrowser
(
MultiScrolledLists
):
class
PathBrowser
(
ClassBrowser
):
def
__init__
(
self
,
flist
):
self
.
flist
=
flist
MultiScrolledLists
.
__init__
(
self
,
flist
.
root
,
4
)
def
longtitle
(
self
):
return
"Path Browser"
def
width
(
self
,
i
):
return
30
def
height
(
self
,
i
):
return
20
def
subtitle
(
self
,
i
):
if
i
==
0
:
return
"Path Entries (sys.path)"
if
i
-
1
>=
len
(
self
.
path
):
return
""
if
i
==
1
:
return
self
.
path
[
0
]
if
i
==
2
:
return
"Classes in "
+
self
.
path
[
1
]
if
i
==
3
:
s
=
self
.
path
[
2
]
i
=
string
.
find
(
s
,
"("
)
if
i
>
0
:
s
=
s
[:
i
]
return
"Methods of "
+
s
return
""
def
items
(
self
,
i
):
if
i
==
0
:
return
sys
.
path
if
i
==
1
:
return
self
.
listmodules
()
if
i
==
2
:
return
self
.
listclasses
()
if
i
==
3
:
return
self
.
listmethods
()
def
listmodules
(
self
):
dir
=
self
.
path
[
0
]
or
os
.
curdir
self
.
init
(
flist
)
def
settitle
(
self
):
self
.
top
.
wm_title
(
"Path Browser"
)
self
.
top
.
wm_iconname
(
"Path Browser"
)
def
rootnode
(
self
):
return
PathBrowserTreeItem
()
class
PathBrowserTreeItem
(
TreeItem
):
def
GetText
(
self
):
return
"sys.path"
def
GetSubList
(
self
):
sublist
=
[]
for
dir
in
sys
.
path
:
item
=
DirBrowserTreeItem
(
dir
)
sublist
.
append
(
item
)
return
sublist
class
DirBrowserTreeItem
(
TreeItem
):
def
__init__
(
self
,
dir
,
packages
=
[]):
self
.
dir
=
dir
self
.
packages
=
packages
def
GetText
(
self
):
if
not
self
.
packages
:
return
self
.
dir
else
:
return
self
.
packages
[
-
1
]
+
": package"
def
GetSubList
(
self
):
try
:
names
=
os
.
listdir
(
self
.
dir
or
os
.
curdir
)
except
os
.
error
:
return
[]
packages
=
[]
for
name
in
names
:
file
=
os
.
path
.
join
(
self
.
dir
,
name
)
if
self
.
ispackagedir
(
file
):
nn
=
os
.
path
.
normcase
(
name
)
packages
.
append
((
nn
,
name
,
file
))
packages
.
sort
()
sublist
=
[]
for
nn
,
name
,
file
in
packages
:
item
=
DirBrowserTreeItem
(
file
,
self
.
packages
+
[
name
])
sublist
.
append
(
item
)
for
nn
,
name
in
self
.
listmodules
(
names
):
item
=
ModuleBrowserTreeItem
(
os
.
path
.
join
(
self
.
dir
,
name
))
sublist
.
append
(
item
)
return
sublist
def
ispackagedir
(
self
,
file
):
if
not
os
.
path
.
isdir
(
file
):
return
0
init
=
os
.
path
.
join
(
file
,
"__init__.py"
)
return
os
.
path
.
exists
(
init
)
def
listmodules
(
self
,
allnames
):
modules
=
{}
suffixes
=
imp
.
get_suffixes
()
allnames
=
os
.
listdir
(
dir
)
sorted
=
[]
for
suff
,
mode
,
flag
in
suffixes
:
i
=
-
len
(
suff
)
...
...
@@ -65,96 +83,13 @@ class PathBrowser(MultiScrolledLists):
sorted
.
append
((
normed_name
,
name
))
allnames
.
remove
(
name
)
sorted
.
sort
()
names
=
[]
for
nn
,
name
in
sorted
:
names
.
append
(
name
)
return
names
def
listclasses
(
self
):
import
pyclbr
dir
=
self
.
path
[
0
]
file
=
self
.
path
[
1
]
name
,
ext
=
os
.
path
.
splitext
(
file
)
if
os
.
path
.
normcase
(
ext
)
!=
".py"
:
self
.
top
.
bell
()
return
[]
try
:
self
.
top
.
configure
(
cursor
=
"watch"
)
self
.
top
.
update_idletasks
()
try
:
dict
=
pyclbr
.
readmodule
(
name
,
[
dir
]
+
sys
.
path
)
finally
:
self
.
top
.
configure
(
cursor
=
""
)
except
ImportError
,
msg
:
tkMessageBox
.
showerror
(
"Import error"
,
str
(
msg
),
parent
=
root
)
return
[]
items
=
[]
self
.
classes
=
{}
for
key
,
cl
in
dict
.
items
():
if
cl
.
module
==
name
:
s
=
key
if
cl
.
super
:
supers
=
[]
for
sup
in
cl
.
super
:
if
type
(
sup
)
is
type
(
''
):
sname
=
sup
else
:
sname
=
sup
.
name
if
sup
.
module
!=
cl
.
module
:
sname
=
"
%
s.
%
s"
%
(
sup
.
module
,
sname
)
supers
.
append
(
sname
)
s
=
s
+
"(
%
s)"
%
string
.
join
(
supers
,
", "
)
items
.
append
((
cl
.
lineno
,
s
))
self
.
classes
[
s
]
=
cl
items
.
sort
()
list
=
[]
for
item
,
s
in
items
:
list
.
append
(
s
)
return
list
def
listmethods
(
self
):
try
:
cl
=
self
.
classes
[
self
.
path
[
2
]]
except
(
IndexError
,
KeyError
):
return
[]
items
=
[]
for
name
,
lineno
in
cl
.
methods
.
items
():
items
.
append
((
lineno
,
name
))
items
.
sort
()
list
=
[]
for
item
,
name
in
items
:
list
.
append
(
name
)
return
list
def
on_double
(
self
,
index
,
i
):
if
i
==
0
:
return
if
i
>=
1
:
dir
=
self
.
path
[
0
]
file
=
self
.
path
[
1
]
name
,
ext
=
os
.
path
.
splitext
(
file
)
if
os
.
path
.
normcase
(
ext
)
!=
".py"
:
self
.
top
.
bell
()
return
fullname
=
os
.
path
.
join
(
dir
,
file
)
edit
=
self
.
flist
.
open
(
fullname
)
if
i
>=
2
:
classname
=
self
.
path
[
2
]
try
:
cl
=
self
.
classes
[
classname
]
except
KeyError
:
cl
=
None
else
:
if
i
==
2
:
edit
.
gotoline
(
cl
.
lineno
)
else
:
methodname
=
self
.
path
[
3
]
edit
.
gotoline
(
cl
.
methods
[
methodname
])
return
sorted
def
main
():
import
PyShell
PathBrowser
(
PyShell
.
flist
)
if
sys
.
stdin
is
sys
.
__stdin__
:
mainloop
()
if
__name__
==
"__main__"
:
main
()
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