def main(args=None): if args is None: args = sys.argv[1:] if '--overlay' in args: args.remove('--overlay') overlay = True else: overlay = False if len(args) < 1 or args[0] == '-': if overlay: print("Can't decompress overlays from stdin", file=stderr) return 2 if hasattr(stdin, 'detach'): f = stdin.detach() else: f = stdin else: try: f = open(args[0], "rb") except IOError as e: print(e, file=stderr) return 2 stdout = sys.stdout if hasattr(stdout, 'detach'): # grab the underlying binary stream stdout = stdout.detach() try: if overlay: decompress_overlay(f, stdout) else: stdout.write(decompress_file(f)) except IOError as e: if e.errno == EPIPE: # don't complain about a broken pipe pass else: raise except (DecompressionError, ) as e: print(e, file=stderr) return 1 return 0
length += 4 else: raise ValueError(count) else: out.write(pack(">B", t)) length += 1 # padding padding = 4 - (length % 4 or 4) if padding: out.write(b'\xff' * padding) def dump_compress_nlz11(input, out): # body length = 0 def dump(): for t in _compress(input, windowclass=NLZ11Window): if type(t) == tuple: yield t from pprint import pprint pprint(list(dump())) if __name__ == '__main__': from sys import stdout, argv data = open(argv[1], "rb").read() stdout = stdout.detach() compress(data, stdout) #compress_nlz11(data, stdout) #dump_compress_nlz11(data, stdout)
length += 4 else: raise ValueError(count) else: out.write(pack(">B", t)) length += 1 # padding padding = 4 - (length % 4 or 4) if padding: out.write(b'\xff' * padding) def dump_compress_nlz11(input, out): # body length = 0 def dump(): for t in _compress(input, windowclass=NLZ11Window): if type(t) == tuple: yield t from pprint import pprint pprint(list(dump())) if __name__ == '__main__': from sys import stdout, argv data = open(argv[1], "rb").read() stdout = stdout.detach() #compress(data, stdout) compress_nlz11(data, stdout) #dump_compress_nlz11(data, stdout)