Register

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

Class for a generic register in a textfile, with a given identifier which is located at the beginning of the line.

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

Checks if the current line matches the identifier of the register.

Parameters:

line (str | bytes) – The candidate line for containing the register information

read(file: IO, storage: str = '', *args, **kwargs) bool[source]

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

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the reading

Return type:

bool

read_register(file: IO, storage: str = '', *args, **kwargs)[source]

Function that reads the register and evaluates the result.

Parameters:

file (IO) – The filepointer

write(file: IO, storage: str = '', *args, **kwargs) bool[source]

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

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the writing

Return type:

bool

write_register(file: IO, storage: str = '', *args, **kwargs)[source]

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

Parameters:

file (IO) – The filepointer

DefaultRegister

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

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

read(file: IO, storage: str = '', *args, **kwargs) bool[source]

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

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the reading

Return type:

bool

write(file: IO, storage: str = '', *args, **kwargs) bool[source]

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

Parameters:

file (IO) – The filepointer

Returns:

The success, or not, in the writing

Return type:

bool