SectionData

class SectionData(root: Section)[source]

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

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

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

Parameters:
  • after (Section) – The existing section which will be appended

  • new (Section) – The new section to add to the data

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

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

Parameters:
  • before (Section) – The existing section which will be preppended

  • new (Section) – The new section to add to the data

append(s: Section) None[source]

Appends a section to the end of the data.

Parameters:

s (Section) – The new section to append to the data

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

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

Parameters:

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

Returns:

Sections filtered by type _T and optional properties

Return type:

_T | list[_T] | None

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

A section generator that only returns sections of type T.

Parameters:

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

Yield:

Sections filtered by type _T

Return type:

Generator[_T, None, None]

preppend(s: Section) None[source]

Appends a section to the beginning of the data.

Parameters:

s (Section) – The new section to preppended to the data.

remove(s: Section) None[source]

Removes an existing section in the chain.

Parameters:

s (Section) – The section to be removed

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

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

Parameters:

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