core#

JLAP reader.

Classes#

JLAP

A more or less complete user-defined wrapper around list objects.

Functions#

keyed_hash(data, key)

Keyed hash.

line_and_pos(→ Iterator[tuple[int, bytes]])

Attributes#

DIGEST_SIZE = 32#
DEFAULT_IV#
keyed_hash(data: bytes, key: bytes)#

Keyed hash.

line_and_pos(lines: Iterable[bytes], pos=0) Iterator[tuple[int, bytes]]#
Parameters:
  • lines -- iterator over input split by 'n', with 'n' removed.

  • pos -- initial position

class JLAP(initlist=None)#

Bases: collections.UserList

A more or less complete user-defined wrapper around list objects.

property body#

All lines except the first, and last two.

property penultimate#

Next-to-last line. Should contain the footer.

property last#

Last line. Should contain the trailing checksum.

classmethod from_lines(lines: Iterable[bytes], iv: bytes, pos=0, verify=True)#
Parameters:
  • lines -- iterator over input split by b'n', with b'n' removed

  • pos -- initial position

  • iv -- initialization vector (first line of .jlap stream, hex decoded). Ignored if pos==0.

  • verify -- assert last line equals computed checksum of previous line. Useful for writing new .jlap files if False.

Raises:

ValueError -- if trailing and computed checksums do not match

Returns:

list of (offset, line, checksum)

classmethod from_path(path: pathlib.Path | str, verify=True)#
add(line: str)#

Add line to buffer, following checksum rules.

Buffer must not be empty.

(Remember to pop trailing checksum and possibly trailing metadata line, if appending to a complete jlap file)

Less efficient than creating a new buffer from many lines and our last iv, and extending.

Returns:

self

terminate()#

Add trailing checksum to buffer.

Returns:

self

write(path: pathlib.Path)#

Write buffer to path.