Adapt IPhotoPlistParser to Python 3.4

This also means that Python 3.3 isn't supported anymore for that part.
Updated README accordingly.
This commit is contained in:
Virgil Dupras 2014-05-03 15:12:13 -04:00
parent ebd7f1b4ce
commit f5f29d775c
2 changed files with 7 additions and 7 deletions

View File

@ -47,7 +47,7 @@ Prerequisites are installed through `pip`. However, some of them are not "pip in
to be installed manually.
* All systems: [Python 3.3+][python] and [setuptools][setuptools]
* Mac OS X: The last XCode to have the 10.7 SDK included.
* Mac OS X: The last XCode to have the 10.7 SDK included. Python 3.4+.
* Windows: Visual Studio 2010, [PyQt 5.0+][pyqt], [cx_Freeze][cxfreeze] and
[Advanced Installer][advinst] (you only need the last two if you want to create an installer)

View File

@ -8,24 +8,24 @@
import plistlib
class IPhotoPlistParser(plistlib.PlistParser):
class IPhotoPlistParser(plistlib._PlistParser):
"""A parser for iPhoto plists.
iPhoto plists tend to be malformed, so we have to subclass the built-in parser to be a bit more
lenient.
"""
def __init__(self):
plistlib.PlistParser.__init__(self)
plistlib._PlistParser.__init__(self, use_builtin_types=True, dict_type=dict)
# For debugging purposes, we remember the last bit of data to be analyzed so that we can
# log it in case of an exception
self.lastdata = ''
def getData(self):
self.lastdata = plistlib.PlistParser.getData(self)
def get_data(self):
self.lastdata = plistlib._PlistParser.get_data(self)
return self.lastdata
def end_integer(self):
try:
self.addObject(int(self.getData()))
self.add_object(int(self.get_data()))
except ValueError:
self.addObject(0)
self.add_object(0)