sections

Flexible tree data structures for organizing lists and dicts into sections.

https://github.com/trevorpogue/sections

class sections.MetaSection[source]

Parses args and kwds passed to a sections() call or Section instantiation and returns a Section tree structure. Parses node names/keys, separate attrs intended for current node vs child nodes, constructs current node, then recursively repeats for all child nodes.

class sections.Section(*args: SectionKeysOrObjects, parent: Optional[SectionParent] = None, **kwds: SectionAttr)[source]

Objects instantiated by Section are nodes in a sections tree structure. Each node has useful methods and properties for organizing lists/dicts into sections and for conveniently accessing/modifying the sub-list/dicts from each section/subsection.

property cls: Type[Section]

The unique structure-wide class of each node.

property entries: Section

A synonym for property leaves.

property sections: Section

A synonym for property children.

structure_change()[source]

Will be called every time there is a change in structure, i.e. whenever a node is added or removed or rearranged in child order. Meant for use when overriding.