Delete dict and subdict items of some name
Gnarlodious
gnarlodious at gmail.com
Tue Dec 18 00:30:48 EST 2012
This problem is solved, I am so proud of myself for figuring it out! After reading some of these ideas I discovered the plist is really lists underneath any "Children" key:
from plistlib import readPlist
def explicate(listDicts):
for dict in listDicts:
if 'FavIcon' in dict:
del dict['FavIcon']
if 'Children' in dict:
dict['Children']=explicate(dict['Children'])
return listDicts
listDicts=readPlist(TARGET_FILE)['Children']
explicate(listDicts)
print(listDicts)
This plist is used by the Mac browser iCab for bookmarks. Removing the Favicon data shrinks the file by about 99% and speeds uploading.
I am glad everyone had a nice discussion about my question, but it wasn't really accurate. Sorry bout that!
-- Gnarlie
More information about the Python-list
mailing list