Skip to content

Instantly share code, notes, and snippets.

@mnordhoff
Last active August 29, 2015 14:01
Show Gist options
  • Save mnordhoff/f655747c22ceec53b58c to your computer and use it in GitHub Desktop.
Save mnordhoff/f655747c22ceec53b58c to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import argparse
import lzma
def compressor(infile, outfile):
with lzma.open(outfile, 'w') as lzf:
lzf.write(infile)
def main(argv):
parser = argparse.ArgumentParser(
prog='squish',
description='''Compress a given file into LZMA package''',
epilog='''SeaBIOS expects a certain kind of LZMA compressed file
to unpack. This tool ensures correct header information
is provided.''',
usage='%(prog)s [options]')
parser.add_argument('-i', '--inputfile', nargs='?',
type=argparse.FileType('r'),
default=sys.stdin, required=True,
help="file to be compressed")
parser.add_argument('-o', '--outputfile', nargs='?',
type=argparse.FileType('w'),
default=sys.stdout,
help="compressed output name")
args = parser.parse_args()
# print(args.inputfile)
compressor(args.inputfile, args.outputfile)
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment