endplay.parsers.pbn
Parser for PBN files
Classes:
Functions:
|
Serialize a list of |
|
Serialize a list of |
|
Read a PBN file object into a list of |
|
Read a PBN string into a list of |
- class endplay.parsers.pbn.PBNDecoder
Bases:
object
Classes:
State
(value)An enumeration.
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)parse_file
(f)Parse a PBN file
Attributes:
- class State(value)
Bases:
Enum
An enumeration.
Attributes:
- COMMENTBLOCK = 3
- DATA = 2
- META = 1
- NONE = 0
- _get_comment(text: str, iscont: 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)
- _parse_conttable(curline)
- _parse_meta(curline)
- _parse_none(curline)
- _tags_to_board()
- parse_file(f: TextIO) list[endplay.types.board.Board]
Parse a PBN file
- re_bcomment_begin = re.compile('\\s*{\\s*(.*)')
- re_bcomment_end = re.compile('(.*)}')
- re_bcomment_line = re.compile('\\s*{\\s*(.*?)}')
- re_colname = re.compile('([+-]?)(\\w+)(?:\\\\(\\d+)([LR]?))?', re.IGNORECASE)
- re_fileformat = re.compile('%\\s*(EXPORT|IMPORT)', re.IGNORECASE)
- re_ignore = re.compile('%.*')
- re_lcomment = re.compile('\\s*;\\s*(.*?)')
- re_metatag = re.compile('%\\s*([\\w-]+):\\s*(.*?)')
- re_note = re.compile('(\\d+):(.*)')
- re_pbnversion = re.compile('%\\s*PBN (\\d+)\\.(\\d+)', re.IGNORECASE)
- re_tagpair = re.compile('\\[(\\w+)\\s+\\"(.*?)\\"\\](\\s*[;{]?.*)')
- endplay.parsers.pbn.dump(boards: list[endplay.types.board.Board], fp: TextIO) None
Serialize a list of
Board
objects to a PBN file
- endplay.parsers.pbn.dumps(boards: list[endplay.types.board.Board]) str
Serialize a list of
Board
objects to a PBN string
- endplay.parsers.pbn.load(fp: TextIO) list[endplay.types.board.Board]
Read a PBN file object into a list of
Board
objects
- endplay.parsers.pbn.loads(s: str) list[endplay.types.board.Board]
Read a PBN string into a list of
Board
objects