Skip to main content

textual-universal-directorytree

DirectoryTree widget for textual, compatible with all filesystems

PyPI PyPI - Python Version Docker Image Version Conda Version GitHub License Testing Status task uv pre-commit docs semantic-release Gitmoji

Installation

pip install textual-universal-directorytree

Extra Dependencies

Some filesystems require additional dependencies to be installed. The remote extra includes all the known optional dependencies. See the Filesystems Supported section for more information.

pip install "textual-universal-directorytree[remote]"

Usage

The below example shows how to use textual-universal-directorytree in a Textual app. It uses the GitHub filesystem to display the contents of the textual GitHub repository. It requires the requests library to be installed (or the remote extra).

from __future__ import annotations

from typing import Any, ClassVar

from rich.syntax import Syntax
from textual import on
from textual.app import App, ComposeResult
from textual.binding import BindingType
from textual.containers import Horizontal, VerticalScroll
from textual.widgets import DirectoryTree, Footer, Header, Static

from textual_universal_directorytree import UniversalDirectoryTree, UPath


class UniversalDirectoryTreeApp(App):
    """
    The power of upath and fsspec in a Textual app
    """

    TITLE = "UniversalDirectoryTree"

    CSS = """
    UniversalDirectoryTree {
        max-width: 50%;
        width: auto;
        height: 100%;
        dock: left;
    }
    """

    BINDINGS: ClassVar[list[BindingType]] = [
        ("q", "quit", "Quit"),
    ]

    def __init__(self, path: str | UPath, *args: Any, **kwargs: Any):
        super().__init__(*args, **kwargs)
        self.universal_path = UPath(path).resolve()
        self.directory_tree = UniversalDirectoryTree(path=self.universal_path)
        self.file_content = Static(expand=True)

    def compose(self) -> ComposeResult:
        yield Header()
        yield Horizontal(self.directory_tree, VerticalScroll(self.file_content))
        yield Footer()

    @on(DirectoryTree.FileSelected)
    def handle_file_selected(self, message: DirectoryTree.FileSelected) -> None:
        """
        Do something with the selected file.

        Objects returned by the FileSelected event are upath.UPath objects and
        they are compatible with the familiar pathlib.Path API built into Python.
        """
        self.sub_title = str(message.path)
        try:
            file_content = message.path.read_text()
        except UnicodeDecodeError:
            self.file_content.update("")
            return None
        lexer = Syntax.guess_lexer(path=message.path.name, code=file_content)
        code = Syntax(code=file_content, lexer=lexer)
        self.file_content.update(code)

Run the above app in your terminal:

python -m textual_universal_directorytree github://juftin:textual-universal-directorytree@main/

Filesystems Supported

textual-universal-directorytree leverages fsspec and universal_pathlib to enable compatibility with local and remote filesystems.

In some cases you need to install a filesystem-specific library to enable compatibility with that filesystem. For example, to enable compatibility with AWS S3 you must install s3fs which is an fsspec implementation for S3.

The following filesystems are known to be supported by textual-universal-directorytree, but it's possible that others filesystems are supported as well and just haven't been tested. If you find a filesystem that works, please open an issue.

File System Format Optional Dependencies
Local path/to/file None
Local file://path/to/file None
AWS S3 s3://bucket/path s3fs
AWS S3 s3a://bucket/path s3fs
Google GCS gs://bucket/path gcsfs
Azure Data Lake adl://bucket/path adlfs
Azure Blob abfs://bucket/path adlfs
Azure Blob az://bucket/path adlfs
GitHub github://owner:repo@branch requests
GitHub github://owner:repo@branch/path requests
SSH ssh://user@host:port/path paramiko
SFTP sftp://user@host:port/path paramiko

License

textual-universal-directorytree is distributed under the terms of the MIT license.

Metadata

Release files for textual-universal-directorytree 1.7.0

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

Source distribution (sdist)

Source distribution for textual-universal-directorytree 1.7.0
File Size Uploaded Provenance
textual_universal_directorytree-1.7.0.tar.gz 154.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for textual-universal-directorytree 1.7.0
File Interpreter ABI Platform
textual_universal_directorytree-1.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 164.2 kB

Release files / textual_universal_directorytree-1.7.0.tar.gz

Download URL textual_universal_directorytree-1.7.0.tar.gz
Size 154.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b6687aa3eb7f9bbd38320328a26de3b8376f4f4c88911a80d49aa8a637bc627e
BLAKE2b-256 checksum
How to use checksums
69b364a99be0b8ffb962b4e865ece1e2d2b8f6d6039e2536a195f41333839699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2025.

Transparency log

Release files / textual_universal_directorytree-1.7.0-py3-none-any.whl

Download URL textual_universal_directorytree-1.7.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
650c4340e737e159a747bafc269f10466f0333c94808bab5996feb45e60be88b
BLAKE2b-256 checksum
How to use checksums
a93887c42a6ad5fb03c0ef2c41aa4f10b040d7af7f8b500442407595e57855d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2025.

Transparency log

Security for textual-universal-directorytree 1.7.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for textual_universal_directorytree-1.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2025.

Transparency log

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.

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