BlockData

class BlockData(root: Block)[source]

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

add_after(after: Block, new: Block)[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)[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)[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) 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)[source]

Appends a block to the beginning of the data.

Parameters:

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

remove(b: Block)[source]

Removes an existing block in the chain.

Parameters:

b (Block) – The block to be removed

remove_blocks_of_type(t: Type[T], **kwargs)[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