def main(args): # Handle command line arguments if len(args) != 2: sys.exit("Usage: python adaptive-huffman-decompress.py InputFile OutputFile") inputfile, outputfile = args # Perform file decompression with open(inputfile, "rb") as inp, open(outputfile, "wb") as out: decompress(huffmancoding.BitInputStream(inp), out)
def decompressor(input_file, output_path): files_name, end = None, None with open(input_file, "r", encoding="latin1") as ninp: files_name, end = get_file_names(ninp) with open(input_file, "rb") as inp: inp.seek(end) bitin = huffmancoding.BitInputStream(inp) canoncode = read_code_len_table(bitin) code = canoncode.to_code_tree() decompress(code, bitin, output_path, files_name)
def main(args): # Handle command line arguments if len(args) != 2: sys.exit("Usage: python huffman-decompress.py InputFile OutputFile") inputfile, outputfile = args # Perform file decompression with open(inputfile, "rb") as inp, open(outputfile, "wb") as out: bitin = huffmancoding.BitInputStream(inp) canoncode = read_code_len_table(bitin) code = canoncode.to_code_tree() decompress(code, bitin, out)
def huffman_decompress(sz_file, de_quant_code, decodeword_refer, de_freq_file): with open(sz_file, "rb") as sz_file_in: bit_in = huffmancoding.BitInputStream(sz_file_in) canonical_code = read_code_len_table(bit_in) code_tree = canonical_code.to_code_tree() f0 = open(decodeword_refer, "w") for c in code_tree.codes: f0.write(f'{c} \n') f0.close() decompress(bit_in, code_tree, de_quant_code) histogram(de_quant_code, de_freq_file)
def main(args): # Coleta argumentos de linha de comando. if len(args) != 2: sys.exit("Usage: python huffman-decompress.py ArquivoEntrada ArquivoSaida") inputfile = args[0] outputfile = args[1] # Realiza descompressao do arquivo bitin = huffmancoding.BitInputStream(open(inputfile, "rb")) out = open(outputfile, "wb") try: canoncode = read_code_len_table(bitin) code = canoncode.to_code_tree() decompress(code, bitin, out) finally: out.close() bitin.close()
def main(args): # Handle command line arguments if len(args) != 2: sys.exit( "Usage: python adaptive-huffman-decompress.py InputFile OutputFile" ) inputfile = args[0] outputfile = args[1] # Perform file decompression bitin = huffmancoding.BitInputStream(open(inputfile, "rb")) out = open(outputfile, "wb") try: decompress(bitin, out) finally: out.close() bitin.close()
def main(args): # Handle command line arguments if len(args) != 2: sys.exit("Usage: python huffman-decompress.py InputFile OutputFile") inputfile = args[0] outputfile = args[1] # Perform file decompression bitin = huffmancoding.BitInputStream(open(inputfile, "rb")) out = open(outputfile, "wb") try: canoncode = read_code_len_table(bitin) code = canoncode.to_code_tree() decompress(code, bitin, out) finally: out.close() bitin.close()
def __init__(self, inputfile, outputfile): self.ipf =huffmancoding.BitInputStream(open(inputfile, "rb")) self.opf = open(outputfile, "wb")