scons icon indicating copy to clipboard operation
scons copied to clipboard

add Gzip builder for compressing files

Open bdbaddog opened this issue 7 years ago • 2 comments

This issue was originally created at: 2009-09-09 01:20:04. This issue was reported by: hsn. hsn said at 2009-09-09 01:20:04

#
# GZip SCons builder
#
# Version 1.0
# 16-Jun-2009
#

import gzip

def GZip(target, source, env=None):
    """Compress files with gzip using default compression level.

    Compress source files into target files using gzip
    compression. No checking on datestamps of possible existing
    target file is done, its always overwritten.

    Keyword arguments:
    target -- list of compressed files to made
    source -- list of files to be compressed
    env -- SCons environment (not used)
    """
    if not isinstance(target, list):
        raise TypeError("target must be list")
    elif not isinstance(source, list):
        raise TypeError("source must be list")
    for i in range(0, len(target)):
        inpf = str(source[i])
        outf = str(target[i])
        out = gzip.open(outf, "wb")
        inp = file(inpf, "rb")
        out.write(inp.read())
        out.close()
        inp.close()
    return None

gregnoel said at 2009-12-09 12:16:11

Bug party triage.

bdbaddog avatar Jan 02 '18 13:01 bdbaddog

Updated to modern raise syntax. Is this something worth pursuing?

mwichmann avatar Jan 22 '23 23:01 mwichmann

Probably worth some effort. Though that patch wouldn't really do it. I'd take the Zip() builder and just swap in gzip calls.

bdbaddog avatar Jan 23 '23 04:01 bdbaddog