Skip to content

Feature: Conditionally rendering based on a property or function #10

@zachriggle

Description

@zachriggle

Currently, all elements in the tree are printed with print_tree.

It would be nice if there were support for an optional argument, say filter which is called before displaying any given tree element. You could then do:

def should_print_node(node):
    return node.someProperty != None

pptree.print_tree(tree, filter=should_print_node)

To only print out node which have a given property. This is useful in filtering the tree without having to manually traverse it and remove child nodes in order to get the "filtered" output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions