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
2cdd6086
Kaydet (Commit)
2cdd6086
authored
Eki 02, 2004
tarafından
Just van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
removed 2.2 support
üst
16c3e089
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
74 deletions
+3
-74
plistlib.py
Lib/plat-mac/plistlib.py
+3
-74
No files found.
Lib/plat-mac/plistlib.py
Dosyayı görüntüle @
2cdd6086
...
@@ -11,8 +11,6 @@ filename or a (writable) file object.
...
@@ -11,8 +11,6 @@ filename or a (writable) file object.
To parse a plist from a file, use the readPlist(pathOrFile)
To parse a plist from a file, use the readPlist(pathOrFile)
function, with a file name or a (readable) file object as the only
function, with a file name or a (readable) file object as the only
argument. It returns the top level object (usually a dictionary).
argument. It returns the top level object (usually a dictionary).
(Warning: you need pyexpat installed for this to work, ie. it doesn't
work with a vanilla Python 2.2 as shipped with MacOS X.2.)
Values can be strings, integers, floats, booleans, tuples, lists,
Values can be strings, integers, floats, booleans, tuples, lists,
dictionaries, Data or Date objects. String values (including dictionary
dictionaries, Data or Date objects. String values (including dictionary
...
@@ -23,10 +21,6 @@ construct (nested) dicts using keyword arguments as well as accessing
...
@@ -23,10 +21,6 @@ construct (nested) dicts using keyword arguments as well as accessing
values with attribute notation, where d.foo is equivalent to d["foo"].
values with attribute notation, where d.foo is equivalent to d["foo"].
Regular dictionaries work, too.
Regular dictionaries work, too.
To support Boolean values in plists with Python < 2.3, "bool", "True"
and "False" are exported. Use these symbols from this module if you
want to be compatible with Python 2.2.x (strongly recommended).
The <data> plist type is supported through the Data class. This is a
The <data> plist type is supported through the Data class. This is a
thin wrapper around a Python string.
thin wrapper around a Python string.
...
@@ -63,10 +57,8 @@ Parse Plist example:
...
@@ -63,10 +57,8 @@ Parse Plist example:
"""
"""
__all__
=
[
"readPlist"
,
"writePlist"
,
"Plist"
,
"Data"
,
"Date"
,
"Dict"
,
__all__
=
[
"readPlist"
,
"writePlist"
,
"Plist"
,
"Data"
,
"Date"
,
"Dict"
]
"False"
,
"True"
,
"bool"
]
# Note: the Plist class has been deprecated.
# Note: the Plist class has been deprecated, Dict, False, True and bool
# are here only for compatibility with Python 2.2.
def
readPlist
(
pathOrFile
):
def
readPlist
(
pathOrFile
):
...
@@ -215,7 +207,7 @@ class Dict(dict):
...
@@ -215,7 +207,7 @@ class Dict(dict):
"""Convenience dictionary subclass: it allows dict construction using
"""Convenience dictionary subclass: it allows dict construction using
keyword arguments (just like dict() in 2.3) as well as attribute notation
keyword arguments (just like dict() in 2.3) as well as attribute notation
to retrieve values, making d.foo
more or less u
quivalent to d["foo"].
to retrieve values, making d.foo
e
quivalent to d["foo"].
"""
"""
def
__new__
(
cls
,
**
kwargs
):
def
__new__
(
cls
,
**
kwargs
):
...
@@ -400,66 +392,3 @@ class PlistParser:
...
@@ -400,66 +392,3 @@ class PlistParser:
self
.
addObject
(
Data
.
fromBase64
(
self
.
getData
()))
self
.
addObject
(
Data
.
fromBase64
(
self
.
getData
()))
def
end_date
(
self
):
def
end_date
(
self
):
self
.
addObject
(
Date
(
self
.
getData
()))
self
.
addObject
(
Date
(
self
.
getData
()))
# cruft to support booleans in Python <= 2.3
import
sys
if
sys
.
version_info
[:
2
]
<
(
2
,
3
):
# Python 2.2 and earlier: no booleans
# Python 2.2.x: booleans are ints
class
bool
(
int
):
"""Imitation of the Python 2.3 bool object."""
def
__new__
(
cls
,
value
):
return
int
.
__new__
(
cls
,
not
not
value
)
def
__repr__
(
self
):
if
self
:
return
"True"
else
:
return
"False"
True
=
bool
(
1
)
False
=
bool
(
0
)
else
:
# Bind the boolean builtins to local names
True
=
True
False
=
False
bool
=
bool
if
__name__
==
"__main__"
:
from
StringIO
import
StringIO
import
time
if
len
(
sys
.
argv
)
==
1
:
pl
=
Dict
(
aString
=
"Doodah"
,
aList
=
[
"A"
,
"B"
,
12
,
32.1
,
[
1
,
2
,
3
]],
aFloat
=
0.1
,
anInt
=
728
,
aDict
=
Dict
(
anotherString
=
"<hello & hi there!>"
,
aUnicodeValue
=
u'M
\xe4
ssig, Ma
\xdf
'
,
aTrueValue
=
True
,
aFalseValue
=
False
,
),
someData
=
Data
(
"<binary gunk>"
),
someMoreData
=
Data
(
"<lots of binary gunk>"
*
10
),
# aDate = Date(time.mktime(time.gmtime())),
)
elif
len
(
sys
.
argv
)
==
2
:
pl
=
readPlist
(
sys
.
argv
[
1
])
else
:
print
"Too many arguments: at most 1 plist file can be given."
sys
.
exit
(
1
)
# unicode keys are possible, but a little awkward to use:
pl
[
u'
\xc5
benraa'
]
=
"That was a unicode key."
f
=
StringIO
()
writePlist
(
pl
,
f
)
xml
=
f
.
getvalue
()
print
xml
f
.
seek
(
0
)
pl2
=
readPlist
(
f
)
assert
pl
==
pl2
f
=
StringIO
()
writePlist
(
pl2
,
f
)
assert
xml
==
f
.
getvalue
()
#print repr(pl2)
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