Created
May 9, 2014 06:41
-
-
Save mnordhoff/a233d15ed5f6b9f0d5b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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