Block

class Block(previous=None, next=None, data=None)[source]

Class for a generic block in a textfile, with given markers for beginning and end and reading states.

classmethod begins(line: str | bytes, storage: str = '')[source]

Checks if the current line marks the beginning of the block.

Parameters:

line (str | bytes) – The candidate line for being the beggining of the block.

classmethod ends(line: str | bytes, storage: str = '')[source]

Checks if the current line marks the end of the block.

Parameters:

line (str | bytes) – The candidate line for being the end of the block.

read(file: IO, *args, **kwargs) bool[source]

Generic function to perform the reading of the block using a filepointer.

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the reading

Return type:

bool

read_block(file: IO, *args, **kwargs)[source]

Function that reads the block and evaluates the result.

Parameters:

file (IO) – The filepointer

write(file: IO, *args, **kwargs) bool[source]

Generic function to perform the writing of the block using a filepointer.

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the writing

Return type:

bool

write_block(file: IO, *args, **kwargs)[source]

Function that writes the block, if it was succesfully read.

Parameters:

file (IO) – The filepointer

DefaultBlock

class DefaultBlock(previous=None, next=None, data=None)[source]

A class for representing a default block, which contains exactly the data from the read line. Mainly used for comments.

read(file: IO, *args, **kwargs) bool[source]

Generic function to perform the reading of the block using a filepointer.

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the reading

Return type:

bool

write(file: IO, *args, **kwargs) bool[source]

Generic function to perform the writing of the block using a filepointer.

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the writing

Return type:

bool