BlockData

class BlockData(root: Block)[source]

Class for a storing, managing and accessing data for a block file.

add_after(after: Block, new: Block) None[source]

Adds a new block to the data after another specified block.

Parameters:
  • after (Block) – The existing block which will be appended

  • new (Block) – The new block to add to the data

add_before(before: Block, new: Block) None[source]

Adds a new block to the data before another specified block.

Parameters:
  • before (Block) – The existing block which will be preppended

  • new (Block) – The new block to add to the data

append(b: Block) None[source]

Appends a block to the end of the data.

Parameters:

b (Block) – The new block to append to the data

get_blocks_of_type(t: type[_T], **kwargs: object) _T | list[_T] | None[source]

A block or block list that only returns blocks of type T that meet given filter requirements passed as kwargs.

Parameters:

t (Type[_T]) – The block type that is desired

Returns:

Blocks filtered by type _T and optional properties

Return type:

_T | list[_T] | None

of_type(t: type[_T]) Generator[_T, None, None][source]

A block generator that only returns blocks of type T.

Parameters:

t (Type[_T]) – The block type that is desired

Yield:

Blocks filtered by type _T

Return type:

Generator[_T, None, None]

preppend(b: Block) None[source]

Appends a block to the beginning of the data.

Parameters:

b (Block) – The new block to preppended to the data.

remove(b: Block) None[source]

Removes an existing block in the chain.

Parameters:

b (Block) – The block to be removed

remove_blocks_of_type(t: type[_T], **kwargs: object) None[source]

Removes a set of blocks given a type and an optional group of filters, similar to get_blocks_of_type()

Parameters:

t (Type[_T]) – The block type that is desired