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
368c0b22
Kaydet (Commit)
368c0b22
authored
Eki 26, 2004
tarafından
Just van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Deprecating Dict class; going through a few hoops to get the warnings right.
üst
7c944875
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
20 deletions
+29
-20
plistlib.py
Lib/plat-mac/plistlib.py
+29
-20
No files found.
Lib/plat-mac/plistlib.py
Dosyayı görüntüle @
368c0b22
...
...
@@ -20,23 +20,17 @@ dictionaries, Data or datetime.datetime objects. String values (including
dictionary keys) may be unicode strings -- they will be written out as
UTF-8.
This module exports a class named Dict(), which allows you to easily
construct (nested) dicts using keyword arguments as well as accessing
values with attribute notation, where d.foo is equivalent to d["foo"].
Regular dictionaries work, too. Dictionaries are always represented with
Dict instances when loading plist data.
The <data> plist type is supported through the Data class. This is a
thin wrapper around a Python string.
Generate Plist example:
pl =
D
ict(
pl =
d
ict(
aString="Doodah",
aList=["A", "B", 12, 32.1, [1, 2, 3]],
aFloat = 0.1,
anInt = 728,
aDict=
D
ict(
aDict=
d
ict(
anotherString="<hello & hi there!>",
aUnicodeValue=u'M
\xe4
ssig, Ma
\xdf
',
aTrueValue=True,
...
...
@@ -53,9 +47,7 @@ Generate Plist example:
Parse Plist example:
pl = readPlist(pathOrFile)
print pl.aKey # same as pl["aKey"]
print pl["aKey"]
"""
...
...
@@ -64,7 +56,7 @@ __all__ = [
"readPlistFromResource"
,
"writePlistToResource"
,
"Plist"
,
"Data"
,
"Dict"
]
# Note: the Plist
class has
been deprecated.
# Note: the Plist
and Dict classes have
been deprecated.
import
base64
import
datetime
...
...
@@ -282,20 +274,26 @@ class PlistWriter(DumbXMLWriter):
self
.
endElement
(
"array"
)
class
Dict
(
dict
):
class
_Internal
Dict
(
dict
):
"""Convenience dictionary subclass: it allows attribute notation
to retrieve values, making d.foo equivalent to d["foo"].
"""
# This class is needed while Dict is scheduled for deprecation:
# we only need to warn when a *user* instantiates Dict or when
# the "attribute notation for dict keys" is used.
def
__getattr__
(
self
,
attr
):
try
:
value
=
self
[
attr
]
except
KeyError
:
raise
AttributeError
,
attr
from
warnings
import
warn
warn
(
"Attribute access from plist dicts is deprecated, use d[key] "
"notation instead"
,
PendingDeprecationWarning
)
return
value
def
__setattr__
(
self
,
attr
,
value
):
from
warnings
import
warn
warn
(
"Attribute access from plist dicts is deprecated, use d[key] "
"notation instead"
,
PendingDeprecationWarning
)
self
[
attr
]
=
value
def
__delattr__
(
self
,
attr
):
...
...
@@ -303,12 +301,23 @@ class Dict(dict):
del
self
[
attr
]
except
KeyError
:
raise
AttributeError
,
attr
from
warnings
import
warn
warn
(
"Attribute access from plist dicts is deprecated, use d[key] "
"notation instead"
,
PendingDeprecationWarning
)
class
Dict
(
_InternalDict
):
def
__init__
(
self
,
**
kwargs
):
from
warnings
import
warn
warn
(
"The plistlib.Dict class is deprecated, use builtin dict instead"
,
PendingDeprecationWarning
)
super
(
Dict
,
self
)
.
__init__
(
**
kwargs
)
class
Plist
(
Dict
):
class
Plist
(
_Internal
Dict
):
"""This class has been deprecated. Use
the Dict with readPlist() and
writePlist() functions instead
.
"""This class has been deprecated. Use
readPlist() and writePlist()
functions instead, together with regular dict objects
.
"""
def
__init__
(
self
,
**
kwargs
):
...
...
@@ -408,7 +417,7 @@ class PlistParser:
# element handlers
def
begin_dict
(
self
,
attrs
):
d
=
Dict
()
d
=
_Internal
Dict
()
self
.
addObject
(
d
)
self
.
stack
.
append
(
d
)
def
end_dict
(
self
):
...
...
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