mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
[#61 state:fixed] Fixed parsing of iPhoto libraries where iPhoto didn't properly escape "&" characters.
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40157
This commit is contained in:
parent
01b06c90b2
commit
0c1854e02a
@ -11,6 +11,7 @@ import os
|
|||||||
import os.path as op
|
import os.path as op
|
||||||
import logging
|
import logging
|
||||||
import plistlib
|
import plistlib
|
||||||
|
import re
|
||||||
|
|
||||||
import objc
|
import objc
|
||||||
from Foundation import *
|
from Foundation import *
|
||||||
@ -108,6 +109,12 @@ class IPhotoLibrary(fs.Directory):
|
|||||||
s = open(unicode(self.plistpath)).read()
|
s = open(unicode(self.plistpath)).read()
|
||||||
# There was a case where a guy had 0x10 chars in his plist, causing expat errors on loading
|
# There was a case where a guy had 0x10 chars in his plist, causing expat errors on loading
|
||||||
s = s.replace('\x10', '')
|
s = s.replace('\x10', '')
|
||||||
|
# It seems that iPhoto sometimes doesn't properly escape & chars. The regexp below is to find
|
||||||
|
# any & char that is not a &-based entity (&, ", etc.). based on TextMate's XML
|
||||||
|
# bundle's regexp
|
||||||
|
s, count = re.subn(r'&(?![a-zA-Z0-9_-]+|#[0-9]+|#x[0-9a-fA-F]+;)', '', s)
|
||||||
|
if count:
|
||||||
|
logging.warning("%d invalid XML entities replacement made", count)
|
||||||
plist = plistlib.readPlistFromString(s)
|
plist = plistlib.readPlistFromString(s)
|
||||||
for photo_data in plist['Master Image List'].values():
|
for photo_data in plist['Master Image List'].values():
|
||||||
self._update_photo(photo_data)
|
self._update_photo(photo_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user