Collection

is_blank(data: Optional[Union[str, List[str]]]) bool

Line is blank if it is either length 0 or contains only spaces.

class Collection(title: str = '', author: str = '', created_at: str = '', updated_at: str = '', notes: str = '')

Collection of one or more game puzzles.

title

Collection title

Type

str

author

Collection author

Type

str

created_at

datetime string of unspecified format (it is not parsed)

Type

str

updated_at

datetime string of unspecified format (it is not parsed)

Type

str

notes

collection notes

Type

List[str]

puzzles

collection puzzles

Type

List[Puzzle]

dump(dst: Union[str, Path, BufferedWriter, TextIOWrapper, FileIO, StringIO, BytesIO])

Saves collection to dst in SokobanYASC .sok format.

Note

Doesn’t care about file extension if dst is path to file.

Parameters

dst – Path to destination file or destination stream object.

dumps() str

Saves collection to str.

load(src: Union[str, Path, BufferedReader, TextIOWrapper, FileIO, StringIO, BytesIO], tessellation_hint: Tessellation = Tessellation.SOKOBAN)

Loads collection from src.

Loader supports SokobanYASC .sok format, but will happily try to load older, similar textual sokoban files (usually with extensions .txt, .tsb or .hsb).

Parameters
  • src – source file path or input stream object

  • tessellation_hint – If puzzles in file don’t specify their game tessellation assume this value.

loads(data: Union[str, bytes], tessellation_hint: Tessellation = Tessellation.SOKOBAN)

Loads collections from data.

Parameters
  • data – raw collection data

  • tessellation_hint – If puzzles in file don’t specify their game tessellation assume this value.

class Rle

Rle encoding and decoding.

classmethod decode(data: Optional[str]) str

Decodes RLE encoded string.

Supports RLE groups, ie strings like “3(a2b)4b”

classmethod encode(line: str) str

RLE encodes string, ie “aaabbbb” becomes “3a4b”.

EOL: Final[str] = '|'
GROUP_END: Final[str] = ')'
GROUP_START: Final[str] = '('