Created
August 8, 2013 09:33
-
-
Save lisael/6183186 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
""" | |
read lz4 compressed files and print them on stdout | |
shell globs allowed | |
""" | |
import sys | |
import glob | |
import argparse | |
import lz4 | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser( | |
description='uncompress a lz4 file and print its content on stdout') | |
parser.add_argument('sources', metavar='FILE', nargs='*', | |
help='compressed files') | |
args = parser.parse_args() | |
files = args.sources | |
if not files: | |
files = [sys.stdin] | |
for name in files: | |
if name is sys.stdin: | |
print lz4.loads(glob.read()) | |
else: | |
for f in glob.glob(name): | |
with open(f,'rb') as stream: | |
print lz4.loads(stream.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment