[Pythonmac-SIG] parsing system_profiler xml output

eichin at metacarta.com eichin at metacarta.com
Thu Nov 11 21:32:52 CET 2004

> format" is probably really plist, since that's the DTD referred to in the
> system_profiler output. Maybe there's a way to do this using plistlib
> instead.

plistlib as-shipped is missing a bunch of things; system profiler
output fails on 

  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/plistlib.py", line 356, in begin_array
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/plistlib.py", line 326, in addObject
    assert self.root is value

which I've seen before but not traced.  iTunes plist importing also
fails, but that's due to:

>>> from xml.utils.iso8601 import parse
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named utils.iso8601

in plistlib.Date.__init__ and toString.  That's at least easy to
kludge around - just copy the definition of plistlib.Date, and make it
pass the date strings back as strings.

(as for the other part, Python's XML story is wierd - when PyXML is
installed it drops some new things into the xml namespace, so having
"import xml" work doesn't actually tell you anything useful.)

More information about the Pythonmac-SIG mailing list