Exemple #1
0
  def compress(self, mode="w", compression=ZIP_DEFLATED, exclude_compress=[]):
    out = VFile("vdir.zip")
    zipfile = ZipFile(out, "w", compression)

    for base, dirnames, dirs, filenames, files in self.walk():
      for name, file in zip(filenames, files):
        path = os.path.join(base, name)
        data = file.getvalue()
        file_compression = ZIP_STORED if name in exclude_compress else compression
        zipfile.writestr(path, data, file_compression)

    out.seek(0)
    return out
Exemple #2
0
  def test_read_write(self):
    data = "foo"

    file = VFile(".emacs")
    file.write(data)

    file.seek(0)

    self.assertEqual(data, file.read())