def unzipString(mystring, filename):
    """Extract a zip compressed string and return it
        
    :param mystring: the compressed string to decompress
    :param filename: the name of the unzipped file"""
    zipresult = six.StringIO(mystring)
    zip = zipfile.ZipFile(zipresult, mode='r', compression=zipfile.ZIP_DEFLATED)
    result = zip.read(filename)
    zip.close()
    zipresult.close()
    return result
def zipString(mystring, filename):
    """Return a zip compressed version of the *mystring* string
        
    :param mystring: The given string
    :param filename: name of the zipped file"""
    zipresult = six.StringIO()
    zip = zipfile.ZipFile(zipresult, mode='w', compression=zipfile.ZIP_DEFLATED)
    zip.writestr(filename, mystring)
    zip.close()
    mystring = zipresult.getvalue()
    zipresult.close()
    return mystring
Beispiel #3
0
 def __init__(self,
              filepath=None,
              output=None,
              docHeader=True,
              encoding='UTF-8',
              omitRoot=False,
              counter=None,
              typeattrs=False,
              typevalue=False):
     self.filepath = filepath
     self.docHeader = docHeader
     self.omitRoot = omitRoot
     self.counter = counter
     self.encoding = encoding
     self.typeattrs = typeattrs
     self.typevalue = typevalue
     if not output:
         if filepath:
             output = open(filepath, 'wt', encoding='utf-8')
         else:
             output = six.StringIO()
     self.output = output