def decode_huffman_block(bits, h_litlen, h_dist):
    """Decode a DEFLATE huffman block using the given decoders."""
    literals = []
    while True:
        # Read a literal, length, or end-of-block symbol.
        litlen = h_litlen.decode(bits)
        if litlen == 256:
            # End of block.
            if literals:
                yield LZLiteral("".join(literals))
            break
        elif litlen < 256:
            # LZLiteral char, buffer it to yield runs as a single string.
            literals.append(chr(litlen))
        else:
            # Yield any buffered literal data.
            if literals:
                yield LZLiteral("".join(literals))
                literals = []
            length = decode_extra_length(bits, litlen)
            dist = h_dist.decode(bits)
            dist = decode_extra_distance(bits, dist)
            yield LZMatch(length, dist)
Decode a DEFLATE huffman block using the given decoders.
tools/compress_memory_initializer.py