Skip to main content

A Functional util for recursive tree processing

Usage

from tree_utils.fs_recursion import RecursionStrategy, ProcessingFunctions, fs_tree_recursion, TreeNodeFunctions, get_children_paths
from tree_utils.tree_recursion import ProcessingFunctions, RecursionStrategy, TreeNodeFunctions

def example_extract_file_paths(root_dir_path: str, options={}, mode=RecursionStrategy.ANY):

    tree_node_functions: TreeNodeFunctions = TreeNodeFunctions()

    def process_file(path: str):
        logging.debug(f"Processing file: {path}")

        print(path)

        # Return the path as the desired content extracted from the node
        return path

    def process_dir(dir_path: str, children_paths: list[str], children_processing_results: list[str]):
        # The paths we returned in 'process_file' are collected and passed to the 'process_dir' function as the children_processing_results

        logging.debug(f"Processing dir: {dir_path}")
        return children_processing_results

    tree_node_functions.is_leaf = os.path.isfile
    tree_node_functions.is_node = os.path.isdir
    tree_node_functions.get_children_ids = get_children_paths
    tree_node_functions.process_leaf = process_file
    tree_node_functions.process_node = process_dir

    return fs_tree_recursion(root_dir_path, tree_node_functions, options, mode=mode)

example_extract_file_paths('/some/path')

Metadata

Release files for recurse-tree-process 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recurse-tree-process 0.0.2
File Size Uploaded Provenance Actions
recurse-tree-process-0.0.2.tar.gz 7.3 kB Without provenance Details for recurse-tree-process-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for recurse-tree-process 0.0.2
File Interpreter ABI Platform Actions
recurse_tree_process-0.0.2-py3-none-any.whl Python 3 none any Details for recurse_tree_process-0.0.2-py3-none-any.whl

Total release size: 15.4 kB

Release files / recurse-tree-process-0.0.2.tar.gz

Download URL recurse-tree-process-0.0.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bf0101826e277c764ce53574af2a3f5d24b051aa38a88cacd81de5f251d75b01
BLAKE2b-256 checksum
How to use checksums
6e8f6cffe74a770e4f6edf8b7fd40c68593209016d78b6d62067fc902973ac08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / recurse_tree_process-0.0.2-py3-none-any.whl

Download URL recurse_tree_process-0.0.2-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1da5cee197642a341331f0f94bdbbc513a6bb8b5917902a9375ff20bf0eac5b
BLAKE2b-256 checksum
How to use checksums
2b17acc04c19167b3ae192a62c9a132ba67382ba8541a0dee8c957cfb55fccc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for recurse-tree-process 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page