Pim Snel wrote:
Op dinsdag 29 november 2005 03:11, schreef aaron@...749...:
I haven't tried this extension yet, or even really read the code. But I don't see why there has to be all this complexity to avoid.
I think its slightlty difficult because the extension has to do two things, which normally are done at different times
- manipulate current svg so it contains relative image-paths
- save the manipulated doc in the archive.
To solve this, I want to let the extension manipulate the temp file which inkscape creates, so it can save the file itself after it has made his modifications.
This should be easy if you override the default output() method of inkex.py to allow you to do what you need (eg. give it a function body of "pass"). Then you should be able to: 1. create a temporary directory in an OS independent way using the tempfile module. 2. copy all images to this directory 3. rename all paths in the in memory copy of the document 4. use python to save the file into the directory 5. zip the directory and give to inkscape
I only have one problem which seems to be a inkscape bug. After the effect is run the file is saved as a normal svg in stead of a ziparchive. You have to do "save as" again. I allready filed a bugreport at https://sourceforge.net/tracker/?group_id=93438&atid=604306
I'm gonna bet this is a problem with inkex.py or the use of it rather than inkscape. As designed inkex.py's output() spits the modified svg back to STDOUT. So what we need to do is either override output in your extension to do what inkscape expects for an output extension or modify inkex.py so that it has a method specific to output extensions. Sorry I didn't comment earlier. Let's get this sorted out. It is a much desired feature.
The bug is not specific for the zip-extension. In my bugreport I give the example with the Connect the Dots effect and the .ps output. In this example you end up with a .ps-file which really is a plain svg-file.
Ok, weird. This sounds like one very good argument for why we shouldn't "save" to filetypes other than SVG. PS output should be an export and certainly shouldn't change the filetype of the working document.
Aaron Spike