Ejemplo n.º 1
0
def huffman(inputfile, outputfile):
    counts = count_chars(inputfile)
    tree = build_tree(counts)
    encoded_data = preserve_tree(tree) + tree.encode_data(inputfile)

    with open(outputfile, 'wb') as f:
        f.write(pack_data(encoded_data))
Ejemplo n.º 2
0
def huffman(inputfile, outputfile):
    counts = count_chars(inputfile)
    tree = build_tree(counts)
    encoded_data = preserve_tree(tree) + tree.encode_data(inputfile)

    with open(outputfile, 'wb') as f:
        f.write(pack_data(encoded_data))
Ejemplo n.º 3
0
 def send(self, client, addr):
     # TODO should send data from all clients to all the other clients
     # TODO Use try catch; remove from connections if error
     # Assuming there's only one server and one client right now
     logging.info("Start sending data.")
     while self.sending:
         client.sendall(utilities.pack_data())
Ejemplo n.º 4
0
 def send(self, client, addr):
     logging.info("Start sending data.")
     while self.sending:
         client.sendall(utilities.pack_data())