How to use the zopfli.gzip function in zopfli

To help you get started, we’ve selected a few zopfli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wnyc / py-zopfli / tests / tests.py View on Github external
data = unittest.__doc__
    def test_reversible(self):
        data = self.data 
        self.assertEquals(self.decompress(self.compress(data)), data)

    def test_iterations_help(self):
        data = self.data
        self.assertTrue(len(self.compress(data, numiterations=1)) > len(self.compress(data, numiterations=1000)))

class ZlibTest(unittest.TestCase, Tests):
    compress = staticmethod(zopfli.zlib.compress)
    decompress = staticmethod(zlib.decompress)

class GzipTest(unittest.TestCase, Tests):

    compress = staticmethod(zopfli.gzip.compress)
    
    def decompress(self, s):
        return gzip.GzipFile(fileobj=StringIO.StringIO(s)).read()
        

if __name__ == "__main__":
    unittest.main()
github saimn / sigal / sigal / plugins / compress_assets.py View on Github external
def do_compress(self, filename, compressed_filename):
        import zopfli.gzip
        with open(filename, 'rb') as f_in, \
                open(compressed_filename, 'wb') as f_out:
            f_out.write(zopfli.gzip.compress(f_in.read()))
github whs / django-static-compress / static_compress / compressors.py View on Github external
def compress(self, path, file):
        return ContentFile(zopfli.compress(file.read()))

zopfli

Zopfli module for python

Apache-2.0
Latest version published 8 months ago

Package Health Score

66 / 100
Full package analysis

Similar packages