views:

141

answers:

2

Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie

archive-dir/2008/11/16/zipfilebypreference.zip

then the next day call it again and it creates another folder. Im sure there is something out there on the internet, who knows?

+1  A: 

You can use java.util.zip, when I was using Jython the built in zip library in python didn't work

Andrew Cox
+3  A: 

You have either the:

 

import  javax.servlet.http.HttpServlet

import  cStringIO
import  gzip
import  string

def compressBuf(buf):
    zbuf = cStringIO.StringIO()
    zfile = gzip.GzipFile(mode = 'wb',  fileobj = zbuf, compresslevel = 6)
    zfile.write(buf)
    zfile.close()
    return zbuf.getvalue()
  • or the direct used of java.util.zip as illustrated here, for one file, or for a all directory content.
VonC