[issue21685] zipfile module doesn't properly compress odt documents

2014-06-09 Thread Raimondo Giammanco

Raimondo Giammanco added the comment:

hit F9 ?!? 
I feel ashamed. The need to recalculate the fields simply slipped my mind. 
Of course, in some way Writer has to be told about the strings replacement. 
Maybe could my fault be partially justifiable if one consider the autoupdate 
behaviour with the uncompressed documents?

Anyway, the workaround to zip without compression is ok for me as LibreOffice 
actually will compress the document on first saving.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21685
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21685] zipfile module doesn't properly compress odt documents

2014-06-09 Thread R. David Murray

R. David Murray added the comment:

So if I'm understanding correctly the python update to the file happens 
correctly in both cases, and the issue with the update not being immediately 
visible is an issue on the OpenOffice side of things.  So I'm closing this as a 
3rd party bug (though it sounds like it may not really be a bug).

--
nosy: +r.david.murray
resolution:  - third party
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21685
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21685] zipfile module doesn't properly compress odt documents

2014-06-08 Thread SilentGhost

SilentGhost added the comment:

Whether for reasons of slightly different setup or due to something else, I'm 
not able to reproduce the issue. What I do see, is that the field is not 
automatically updated, so on opening of the document I have to hit F9 to get 
the answer field updated. That doesn't, however, seem at all related to the 
compression method (that is I do get the same behaviour for any combination of 
compression level values). Perhaps someone else would have a better idea.

--
nosy: +alanmcintyre

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21685
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21685] zipfile module doesn't properly compress odt documents

2014-06-07 Thread Raimondo Giammanco

New submission from Raimondo Giammanco:

Steps to reproduce
¯¯
-1- Create a document.odt containing an input (text) field and a conditional 
text field; the latter will show a different text based upon the content of the 
input text field. [use attached example.odt]
-2- Edit the file by means of following code

from zipfile import ZipFile, ZIP_DEFLATED
document = '/tmp/example.odt' # SET ME PLEASE
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)

-3- Open example.odt with *office

As `REPLACEMENT' is the requested string, one expect to see the relevant 
conditional text
What happens: the LO function doesn't recognize the string, unless one do not 
retype it manually

Omitting ZIP_DEFLATED parameter prevents this behaviour from happen (so letting 
zipfile use the default no-compression method) 


tested on
Python 2.7.3 and Python 3.2.3
Ubuntu 12.04 amd64
LibreOffice Version 4.0.4.2

--
components: Library (Lib)
files: example.odt
messages: 219933
nosy: rai
priority: normal
severity: normal
status: open
title: zipfile module doesn't properly compress odt documents
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file35511/example.odt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21685
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21685] zipfile module doesn't properly compress odt documents

2014-06-07 Thread SilentGhost

SilentGhost added the comment:

Raimondo, the documentation clearly states that the compression method is 
either inherited from ZipInfo instance (when that one is passed) or set to 
ZIP_STORED otherwise. Since you're not passing ZipInfo instance, but the string 
(as the first argument to .writestr), therefore the compression method is set 
to ZIP_STORED. If you're not set it to ZIP_DEFLATED explicitly, it would work 
as you expect it. In either case, this behaviour is in accordance with the 
documentation.

--
nosy: +SilentGhost

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21685
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21685] zipfile module doesn't properly compress odt documents

2014-06-07 Thread Raimondo Giammanco

Raimondo Giammanco added the comment:

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)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21685
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com