T0ha / ezodf

ezodf is a Python package to create new or open existing OpenDocument (ODF) files to extract, add, modify or delete document data, forked from dead project https://bitbucket.org/mozman/ezodf
Other
61 stars 23 forks source link

Support reading from and writing to memory #4

Closed chfw closed 9 years ago

chfw commented 9 years ago

Hi,

ezodf lacks of such support while odfpy had it. I originally aimed at "ods" file type only but it turns out "odt", "odg" and "odp" are OK with my patches too.

The patches only modifies the behavior of file opening and file save. Although it causes back compatibility concerns because opendoc was inserted a file_content parameter, I don't think opening from a memory stream ever worked. Hence, it is pretty safe to add such an extra paramter. Test cases were appended.

I am looking forward to its release in pypi as my library pyexcel-ods3 would like to have this support.

Cheers

chfw

michael-k commented 9 years ago

@T0ha: any plans on merging this?

T0ha commented 9 years ago

Thanks. Sorry was a bit busy.

T0ha commented 9 years ago

I'll include it in next package

chfw commented 9 years ago

Excellent news. I am looking forward to the new release.

T0ha commented 9 years ago

May be I'm wrong, but what's file_content for? Are you going to open file and ByteStream at once? Seems it's better to check if filename instance of StringIO or string.

chfw commented 9 years ago

I am sorry for the late response. I got some time today to revisit why I added file_content.

Originally, file_content was intended to be place holder for the content in memory. Because my content came in as , and I have not wrapped it with StringIO, hence opendoc confuses it with filename and initializes fm as FileManager instead of BytesStreamManager. For that reason, I added 'file_content'.

Your subsequent commit to remove 'file_content' is nicer solution. I am looking forward to the pypi release.

T0ha commented 9 years ago

Thanks, all. I'm happy it works for you. If we accept it works I'll pack next minor release.