[Python-checkins] python/dist/src/Mac/Lib plistlib.py,1.3,1.4
jvr@users.sourceforge.net
jvr@users.sourceforge.net
Wed, 20 Nov 2002 12:47:58 -0800
Update of /cvsroot/python/python/dist/src/Mac/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv9953
Modified Files:
plistlib.py
Log Message:
- cleaned up example/test code
- don't encode/escape elements
- fixed typo in doc string
- provide our own copy function for the Dict class
Index: plistlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/plistlib.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** plistlib.py 19 Nov 2002 23:11:49 -0000 1.3
--- plistlib.py 20 Nov 2002 20:47:55 -0000 1.4
***************
*** 35,51 ****
pl = Plist(
! Foo="Doodah",
! aList=["A", "B", 12, 32.1, [1, 2, 3]],
! aFloat = 0.1,
! anInt = 728,
! aDict=Dict(
! aString="<hello & hi there!>",
! SomeUnicodeValue=u'M\xe4ssig, Ma\xdf',
! someTrueValue=True,
! someFalseValue=False,
! ),
! someData = Data("hello there!"),
! someMoreData = Data("hello there! " * 10),
! aDate = Date(time.mktime(time.gmtime())),
)
# unicode keys are possible, but a little awkward to use:
--- 35,51 ----
pl = Plist(
! 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\xe4ssig, Ma\xdf',
! aTrueValue=True,
! aFalseValue=False,
! ),
! someData = Data("<binary gunk>"),
! someMoreData = Data("<lots of binary gunk>" * 10),
! aDate = Date(time.mktime(time.gmtime())),
)
# unicode keys are possible, but a little awkward to use:
***************
*** 79,83 ****
def beginElement(self, element):
self.stack.append(element)
- element = _encode(element)
self.writeln("<%s>" % element)
self.indentLevel += 1
--- 79,82 ----
***************
*** 91,95 ****
def simpleElement(self, element, value=None):
if value:
- element = _encode(element)
value = _encode(value)
self.writeln("<%s>%s</%s>" % (element, value, element))
--- 90,93 ----
***************
*** 173,177 ****
class Dict:
! """Dict wrapper for convenient acces of values through attributes."""
def __init__(self, **args):
--- 171,175 ----
class Dict:
! """Dict wrapper for convenient access of values through attributes."""
def __init__(self, **args):
***************
*** 190,193 ****
--- 188,194 ----
__repr__ = __str__
+ def copy(self):
+ return self.__class__(**self.__dict__)
+
def __getattr__(self, attr):
"""Delegate everything else to the dict object."""
***************
*** 401,417 ****
if len(sys.argv) == 1:
pl = Plist(
! Foo="Doodah",
! aList=["A", "B", 12, 32.1, [1, 2, 3]],
! aFloat = 0.1,
! anInt = 728,
! aDict=Dict(
! aString="<hello & hi there!>",
! SomeUnicodeValue=u'M\xe4ssig, Ma\xdf',
! someTrueValue=True,
! someFalseValue=False,
! ),
! someData = Data("hello there!"),
! someMoreData = Data("hello there! " * 10),
! aDate = Date(time.mktime(time.gmtime())),
)
elif len(sys.argv) == 2:
--- 402,418 ----
if len(sys.argv) == 1:
pl = Plist(
! 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\xe4ssig, 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: