This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rai
Recipients SilentGhost, rai
Date 2014-06-07.23:57:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1402185449.16.0.249672933107.issue21685@psf.upfronthosting.co.za>
In-reply-to
Content
SilentGhost, thank you for your reply but I am probably missing something with it. Maybe there is some misunderstanding because of my unclear report. Please let me sum up my point and excuse some repetitiveness

From the documentation of .writestr:
``If given, compress_type overrides the value given for the compression parameter to the constructor for the new entry``
I believed to understand that .writestr would have used the same compression_type passed creating the `z' instance. So, having already passed ZIP_DEFLATED to the constructor, in my opinion, passing it again would have been an useless repetition.

However, as per your suggestion,I tried to explicitly pass ZIP_DEFLATED to .writestr too:

from zipfile import ZipFile, ZIP_DEFLATED
document = '/tmp/example.odt'
S2b, R2b = 'SUBST'.encode(), 'REPLACEMENT'.encode()
with ZipFile(document,'a', ZIP_DEFLATED) as z:
	xmlString = z.read('content.xml')
	xmlString = xmlString.replace(S2b, R2b)
    z.writestr('content.xml', xmlString, ZIP_DEFLATED)

but to no avail: with and without passing ZIP_DEFLATED to .writestr the odt documents lose the feature explained in my first post

AFAICT, the only way to keep a fully functional odt document is not to compress it (no ZIP_DEFLATED at all), as cited in my previous post 

with ZipFile(document,'a') as z:
	xmlString = z.read('content.xml')
	xmlString = xmlString.replace(S2b, R2b)
    z.writestr('content.xml', xmlString)
History
Date User Action Args
2014-06-07 23:57:29raisetrecipients: + rai, SilentGhost
2014-06-07 23:57:29raisetmessageid: <1402185449.16.0.249672933107.issue21685@psf.upfronthosting.co.za>
2014-06-07 23:57:29railinkissue21685 messages
2014-06-07 23:57:28raicreate