pandagg.tree.mapping module

class pandagg.tree.mapping.Mapping(from_=None, identifier=None, properties=None, dynamic=False)[source]

Bases: pandagg.tree._tree.Tree

contains(nid)[source]

Check if the tree contains node of given id

classmethod deserialize(from_, depth=0)[source]
list_nesteds_at_field(field_path)[source]
mapping_type_of_field(field_path)[source]
nested_at_field(field_path)[source]
node_class

alias of pandagg.node.mapping.abstract.Field

node_path(nid)[source]
serialize()[source]
show(data_property='pretty', **kwargs)[source]

Print the tree structure in hierarchy style.

You have three ways to output your tree data, i.e., stdout with show(), plain text file with save2file(), and json string with to_json(). The former two use the same backend to generate a string of tree structure in a text graph.

  • Version >= 1.2.7a*: you can also specify the line_type parameter, such as ‘ascii’ (default), ‘ascii-ex’, ‘ascii-exr’, ‘ascii-em’, ‘ascii-emv’, ‘ascii-emh’) to the change graphical form.
Parameters:
  • nid – the reference node to start expanding.
  • level – the node level in the tree (root as level 0).
  • idhidden – whether hiding the node ID when printing.
  • filter – the function of one variable to act on the Node object. When this parameter is specified, the traversing will not continue to following children of node whose condition does not pass the filter.
  • key – the key param for sorting Node objects in the same level.
  • reverse – the reverse param for sorting Node objects in the same level.
  • line_type
  • data_property – the property on the node data object to be printed.
Returns:

None

validate_agg_node(agg_node, exc=True)[source]

Ensure if node has field or path that it exists in mapping, and that required aggregation type if allowed on this kind of field. :param agg_node: AggNode you want to validate on this mapping :param exc: boolean, if set to True raise exception if invalid :rtype: boolean