Simple test

Ensure your device works with this simple test.

examples/pathlib_simpletest.py
 1# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
 2#
 3# SPDX-License-Identifier: MIT
 4import adafruit_pathlib
 5
 6
 7def print_directory_tree(path: adafruit_pathlib.Path, prefix: str = ""):
 8    """Recursively prints an ASCII tree of the given directory."""
 9    if not path.is_dir():
10        print(f"{path} is not a directory.")
11        return
12
13    entries = sorted(path.iterdir(), key=lambda x: (not x.is_dir(), x.name.lower()))
14    for index, entry in enumerate(entries):
15        connector = "|-- " if index < len(entries) - 1 else "'-- "
16        print(f"{prefix}{connector}{entry.name}")
17        if entry.is_dir():
18            extension = "|   " if index < len(entries) - 1 else "    "
19            print_directory_tree(entry, prefix + extension)
20
21
22dir_path = adafruit_pathlib.Path("/lib")
23
24print_directory_tree(dir_path)