MCPcopy Create free account
hub / github.com/ActiveState/code / _encode

Function _encode

recipes/Python/578062_Markov/recipe-578062.py:353–363  ·  view source on GitHub ↗
(bytes_obj, byte_map, grid, index, block_size)

Source from the content-addressed store, hash-verified

351# block_size
352# - length of each edge in a grid
353def _encode(bytes_obj, byte_map, grid, index, block_size):
354 cache = bytes()
355 index = [0] + index
356 for byte in bytes_obj:
357 if byte in byte_map:
358 index.append(byte_map[byte])
359 index = index[1:]
360 cache += bytes([eval_index(grid, block_size, index)])
361 else:
362 cache += bytes([byte])
363 return cache, index[1:]
364
365# bytes_obj
366# - the bytes to encode

Callers 1

encryptFunction · 0.70

Calls 3

bytesFunction · 0.85
eval_indexFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected