Source code for pyiron_contrib.protocol.utils.pptree

# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.


import sys

"""
this module provides a function to nicely print the whitelists
"""


__author__ = "Dominik Gehringer, Liam Huber"
__copyright__ = "Copyright 2019, Max-Planck-Institut für Eisenforschung GmbH " \
                "- Computational Materials Design (CM) Department"
__version__ = "0.0"
__maintainer__ = "Liam Huber"
__email__ = "huber@mpie.de"
__status__ = "development"
__date__ = "Dec 12, 2019"


[docs]def count_paths(node): """ Counts the entries in a nested dectionaries Args: node: (dict) the nested dictionary Returns: (int) the number of total leaf nodes """ if not isinstance(node, dict): return 1 else: s = 0 for _, v in node.items(): s += count_paths(v) return s