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
927bc451
Kaydet (Commit)
927bc451
authored
Ara 01, 2002
tarafından
Just van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
- reworked the object unpacking code, now supports new-style objects more
or less decently/completely. - cleaned up a little.
üst
6a8c5183
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
34 deletions
+46
-34
PyBrowser.py
Mac/Tools/IDE/PyBrowser.py
+46
-34
No files found.
Mac/Tools/IDE/PyBrowser.py
Dosyayı görüntüle @
927bc451
...
...
@@ -502,33 +502,53 @@ class Browser:
SIMPLE_TYPES
=
(
types
.
NoneType
,
types
.
IntType
,
types
.
LongType
,
types
.
FloatType
,
types
.
ComplexType
,
types
.
StringType
type
(
None
),
int
,
long
,
float
,
complex
,
str
,
unicode
,
)
INDEXING_TYPES
=
(
types
.
TupleType
,
types
.
ListType
,
types
.
DictionaryType
)
def
get_ivars
(
obj
):
"""Return a list the names of all (potential) instance variables."""
# __mro__ recipe from Guido
slots
=
{}
# old-style C objects
if
hasattr
(
obj
,
"__members__"
):
for
name
in
obj
.
__members__
:
slots
[
name
]
=
None
if
hasattr
(
obj
,
"__methods__"
):
for
name
in
obj
.
__methods__
:
slots
[
name
]
=
None
# generic type
if
hasattr
(
obj
,
"__dict__"
):
slots
.
update
(
obj
.
__dict__
)
cls
=
type
(
obj
)
if
hasattr
(
cls
,
"__mro__"
):
# new-style class, use descriptors
for
base
in
cls
.
__mro__
:
for
name
,
value
in
base
.
__dict__
.
items
():
# XXX using callable() is a heuristic which isn't 100%
# foolproof.
if
hasattr
(
value
,
"__get__"
)
and
not
callable
(
value
):
slots
[
name
]
=
None
if
"__dict__"
in
slots
:
del
slots
[
"__dict__"
]
slots
=
slots
.
keys
()
slots
.
sort
()
return
slots
def
unpack_object
(
object
,
indent
=
0
):
tp
=
type
(
object
)
if
tp
in
SIMPLE_TYPES
and
tp
is
not
types
.
NoneTyp
e
:
if
isinstance
(
object
,
SIMPLE_TYPES
)
and
object
is
not
Non
e
:
raise
TypeError
,
"can't browse simple type:
%
s"
%
tp
.
__name__
elif
tp
==
types
.
DictionaryType
:
elif
isinstance
(
object
,
dict
)
:
return
unpack_dict
(
object
,
indent
)
elif
tp
in
(
types
.
TupleType
,
types
.
ListType
):
elif
isinstance
(
object
,
(
tuple
,
list
)
):
return
unpack_sequence
(
object
,
indent
)
elif
tp
==
types
.
InstanceType
:
return
unpack_instance
(
object
,
indent
)
elif
tp
==
types
.
ClassType
:
return
unpack_class
(
object
,
indent
)
elif
tp
==
types
.
ModuleType
:
elif
isinstance
(
object
,
types
.
ModuleType
):
return
unpack_dict
(
object
.
__dict__
,
indent
)
else
:
return
unpack_other
(
object
,
indent
)
...
...
@@ -555,23 +575,15 @@ def unpack_class(clss, indent = 0):
return
pack_items
(
items
,
indent
)
def
unpack_other
(
object
,
indent
=
0
):
attrs
=
[]
if
hasattr
(
object
,
'__members__'
):
attrs
=
attrs
+
object
.
__members__
if
hasattr
(
object
,
'__methods__'
):
attrs
=
attrs
+
object
.
__methods__
if
hasattr
(
object
,
'__dict__'
):
attrs
=
attrs
+
object
.
__dict__
.
keys
()
if
hasattr
(
object
,
'__slots__'
):
# XXX??
attrs
=
attrs
+
object
.
__slots__
if
hasattr
(
object
,
"__class__"
)
and
"__class__"
not
in
attrs
:
attrs
.
append
(
"__class__"
)
if
hasattr
(
object
,
"__doc__"
)
and
"__doc__"
not
in
attrs
:
attrs
.
append
(
"__doc__"
)
attrs
=
get_ivars
(
object
)
items
=
[]
for
attr
in
attrs
:
items
.
append
((
attr
,
getattr
(
object
,
attr
)))
try
:
value
=
getattr
(
object
,
attr
)
except
:
pass
else
:
items
.
append
((
attr
,
value
))
return
pack_items
(
items
,
indent
)
def
pack_items
(
items
,
indent
=
0
):
...
...
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