endplay.parsers.pbn

Parser for PBN files

Classes:

PBNDecoder()

Functions:

dump(boards, fp)

Serialize a list of Board objects to a PBN file

dumps(boards)

Serialize a list of Board objects to a PBN string

load(fp)

Read a PBN file object into a list of Board objects

loads(s)

Read a PBN string into a list of Board objects

class endplay.parsers.pbn.PBNDecoder

Bases: object

Classes:

State(*values)

Methods:

_get_comment(text, iscont)

Returns the comment contained in text, and a flag which is set to True if the comment requires continuation or False otherwise

_parse_commentblock(curline)

_parse_conttable(curline)

_parse_meta(curline)

_parse_none(curline)

_tags_to_board()

clear()

parse_file(f)

Parse a PBN file

Attributes:

boards

curtag

curtags

lineno

metadata

notes

prevtags

state

class State(*values)

Bases: Enum

Attributes:

COMMENTBLOCK

DATA

META

NONE

COMMENTBLOCK = 3
DATA = 2
META = 1
NONE = 0
_get_comment(text: str, iscont: bool) tuple[str | None, bool]

Returns the comment contained in text, and a flag which is set to True if the comment requires continuation or False otherwise

_parse_commentblock(curline: str) bool
_parse_conttable(curline: str) bool
_parse_meta(curline: str) bool
_parse_none(curline: str) bool
_tags_to_board() Board | None
boards: list[Board]
clear() None
curtag: str | None
curtags: dict[str, Any]
lineno: int
metadata: dict[str, Any]
notes: dict[str, str]
parse_file(f: IO[str]) list[Board]

Parse a PBN file

prevtags: dict[str, Any]
state: State
endplay.parsers.pbn.dump(boards: list[Board], fp: IO[str]) None

Serialize a list of Board objects to a PBN file

endplay.parsers.pbn.dumps(boards: list[Board]) str

Serialize a list of Board objects to a PBN string

endplay.parsers.pbn.load(fp: IO[str]) list[Board]

Read a PBN file object into a list of Board objects

endplay.parsers.pbn.loads(s: str) list[Board]

Read a PBN string into a list of Board objects