MCPcopy Create free account
hub / github.com/secdev/scapy / huffman_compute_decode_tree

Method huffman_compute_decode_tree

scapy/contrib/http2.py:1153–1173  ·  view source on GitHub ↗

huffman_compute_decode_tree initializes/builds the static_huffman_tree :return: None :raises: InvalidEncodingException if there is an encoding problem

(cls)

Source from the content-addressed store, hash-verified

1151
1152 @classmethod
1153 def huffman_compute_decode_tree(cls):
1154 # type: () -> None
1155 """ huffman_compute_decode_tree initializes/builds the static_huffman_tree
1156
1157 :return: None
1158 :raises: InvalidEncodingException if there is an encoding problem
1159 """
1160 cls.static_huffman_tree = HuffmanNode(None, None)
1161 i = 0
1162 for entry in cls.static_huffman_code:
1163 parent = cls.static_huffman_tree
1164 for idx in range(entry[1] - 1, -1, -1):
1165 b = (entry[0] >> idx) & 1
1166 if isinstance(parent[b], bytes):
1167 raise InvalidEncodingException('Huffman unique prefix violation :/') # noqa: E501
1168 if idx == 0:
1169 parent[b] = chb(i) if i < 256 else EOS()
1170 elif parent[b] is None:
1171 parent[b] = HuffmanNode(None, None)
1172 parent = parent[b]
1173 i += 1
1174
1175 def __init__(self, s):
1176 # type: (str) -> None

Callers 1

huffman_decodeMethod · 0.80

Calls 4

chbFunction · 0.90
HuffmanNodeClass · 0.85
EOSClass · 0.85

Tested by

no test coverage detected