
[I wrote]
- It can only add disk files. The ability to write data to a zip entry through a file-like object or from a string would make it more like an API, IMHO
[JimA wrote]
I could add a method writestr(self, string, year, month, day, hour, minute, second, ...) There are a lot of fields required which usually come from the file.
Something like that seems fine to me. [I wrote]
- Some kind of access to the TOC entry fields (date, size, compressed size etc) also seems like a nice feature.
[JimA answers]
This access is provided directly by self.TOC, and the fields are documented.
Good enough. My bad, I was looking for getter methods. (me being a java dude) [I wrote]
I admit that I am fond of the api from java.util.zip.ZipFile and java.util.zip.ZipOutputStream.
[JimA asks]
I don't know this API. If writestr() is not sufficient, what API would you like?
This is only meant as a source for inspiration, certainly as a request for change. writestr would answer my complaint nicely. Below, only one ZipEntry can be actively read or written to at a time. All the small details of performance and implementation complexity are ignored. class ZipFile: def getEntry(name): ... self.activeentry = ZipEntry(name) return self.activeentry class ZipEntry: #enough methods and fields to fake file-ness to casual users like me. def write(list): ... def writelines(str): ... def read(size=None): ... def readlines(sizehint=-1): ... def seek(offset): ... def flush(): ... def close(str): ... def getSize(): .... def getCompressedSize(): .... def getFlags(): .... regards, finn