spekk.trees.registry

spekk.trees.registry#

Module for abstracting over tree-like data structures; in essence, everything that is tree-like can be represented as a mapping of keys and values.

Functions

dispatch_by_duck_type(tree)

Given a tree, return a TreeDef if it has the required dunder-methods.

dispatch_by_type(tree)

Given a tree, return the TreeDef for its type (through the type_registry).

dispatch_treedef(tree)

If the tree itself is a TreeDef, return it.

has_treedef(tree)

Return True if a TreeDef is registered for the given tree.

register_dispatch_fn(dispatch_fn)

Register a new TreeDef by dispatch function.

register_type(t, treedef)

Register a new TreeDef by type.

treedef(tree)

Return the TreeDef (if registered) for the given tree (dict, list, and tuple are registered by default).

Classes

DuckTypedTreeDef(obj)

An object can be a TreeDef if it has the dunder-methods: __spekk_treedef_keys__, __spekk_treedef_get__, and __spekk_treedef_create__.

TreeDef(tree)

A TreeDef is an abstraction for a tree-like data structure.