I'm trying to modify a plist file. The modification works properly, but I'm having difficulties in finding the proper way to restore.
The file contains HTML strings like "$#226;" and either this gets replaced by "รข" (which I don't want) but the programme completes or the program fails when I try to use the data wrapper. I must be doing something wrong, but can't find what (and this includes Google searches). Please help. Failing text: def omkattenAgents(AANGRIJPINGSPUNT, KLANTNAAM_OUT, KLANTNAAM_IN, ZOEKSET1_OUT, ZOEKSET1_IN, ZOEKSET2_OUT, ZOEKSET2_IN): <other programme text> tussentekst = plistlib.Data(plistlib.readPlist(os.path.join(root,bestandsnaam))) tussenblok = tussentekst.data ding = tussenblok['RepresentedObject'] tekststring = ding.get('Name') tekststring_0 = tekststring.replace(KLANTNAAM_OUT,KLANTNAAM_IN) tekststring_1 = tekststring_0.replace(ZOEKSET1_OUT,ZOEKSET1_IN) tekststring_2 = tekststring_1.replace(ZOEKSET2_OUT,ZOEKSET2_IN) tekststring_3 = tekststring_2.replace(ZOEKSET1_OUT_LOWER,ZOEKSET1_IN_LOWER) tekststring_4 = tekststring_3.replace(ZOEKSET2_OUT_LOWER,ZOEKSET2_IN_LOWER) ding['Name'] = tekststring_4 tussenblok['RepresentedObject'] = ding tussentekst.data = tussenblok plistlib.Data(plistlib.writePlist(tussentekst, os.path.join(root,bestandsnaam))) Text in Terminal: File "LeadDevice_klant_nieuw_aanmaken.py", line 66, in <module> omkattenAgents(AANGRIJPINGSPUNT, KLANTNAAM_OUT, KLANTNAAM_IN, ZOEKSET1_OUT, ZOEKSET1_IN, ZOEKSET2_OUT, ZOEKSET2_IN) File "/Volumes/LeadDevice-2/LeadDevice/Programmatuur/Python/ LeadDeviceProductie/LeadDevice_klant_nieuw_naamcorrectie_intern.py", line 162, in omkattenAgents plistlib.Data(plistlib.writePlist(tussentekst, os.path.join(root,bestandsnaam))) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/plistlib.py", line 94, in writePlist writer.writeValue(rootObject) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/plistlib.py", line 254, in writeValue self.writeData(value) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/plistlib.py", line 267, in writeData for line in data.asBase64(maxlinelength).split("\n"): File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/plistlib.py", line 379, in asBase64 return _encodeBase64(self.data, maxlinelength) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/plistlib.py", line 361, in _encodeBase64 chunk = s[i : i + maxbinsize] TypeError: unhashable type The difference between failure and completion with replacing HTML is the statement tussentekst.data = tussenblok (failure) tussentekst = tussenblok (completion with replacing) Regards, Bob -- http://mail.python.org/mailman/listinfo/python-list