Skip to content

Instantly share code, notes, and snippets.

@mnordhoff
Created May 9, 2014 06:41
Show Gist options
  • Save mnordhoff/a233d15ed5f6b9f0d5b6 to your computer and use it in GitHub Desktop.
Save mnordhoff/a233d15ed5f6b9f0d5b6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import getopt
import lzma
def compressor(infile, outfile):
with lzma.open(outfile, "w") as f:
f.write(infile)
def usage():
print ('test.py -i <inputfile> -o <outputfile>')
def main(argv):
inputfile = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv, "hi:o:", ["ifile=", "ofile="])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
usage()
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
print ('Input file is "', inputfile)
print ('Output file is "', outputfile)
compressor(inputfile, 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