Skip to main content

dirclass

Treat a directory like a dataclass for ease, recursively.

Main features

  • Simple factory: dirclass(path, recursive=True, file_types="*") -> dataclass
  • List files: d.all() returns a flattened list of file paths
  • Read files: d.read_all() returns a flattened list of file contents
  • Filtering: Accept glob patterns like "*.py" or ["*.py", "*.md"] in constructor or per-call
  • Subfolder properties: Immediate subfolders become attributes (e.g., .src, .data)
    • Aliases: full sanitized name, tail after last dot (e.g., path.src → .path_src and .src), and case-insensitive access (e.g., .Gallery and .gallery)
  • Robust reading: Read errors are logged and skipped (continues processing)

Install (PyPI)

pip install dirclass

Alternatively,

pip install -e .

Usage

from dirclass import dirclass

# Create a directory wrapper
d = dirclass("/path/to/folder", recursive=True, file_types=["*.py", "*.md"])

# List all matching files
paths = d.all()                 # list[str]

# Read contents of all matching files
contents = d.read_all()         # list[str]

# Override filters per call
py_only = d.all("*.py")
md_and_txt_contents = d.read_all(["*.md", "*.txt"])

# Subfolder properties (immediate children of the root)
# If your root has folders: src, data, and Gallery
src_files = d.src               # files under /path/to/folder/src
data_files = d.data             # files under /path/to/folder/data
gallery_files = d.Gallery       # case-insensitive access also works: d.gallery

# Dotted folder names (e.g., `path.src`) expose multiple aliases
# - full sanitized name: d.path_src
# - tail alias: d.src

Example

from dirclass import dirclass

d = dirclass("./project", recursive=True, file_types=["*.py", "*.md"]) 

print("All files:")
for p in d.all():
    print(p)

print("\nPython files only:")
for p in d.all("*.py"):
    print(p)

print("\nSubfolder: src")
for p in d.src:  # requires a ./project/src subfolder
    print(p)

print("\nReading markdown contents:")
for content in d.read_all("*.md"):
    print(content[:80], "...")

Codes are generated by GPT5, thus may not be reliable in the current version for test.

Metadata

Release files for dirclass 0.1.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 dirclass 0.1.0
File Size Uploaded Provenance
dirclass-0.1.0.tar.gz 5.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dirclass 0.1.0
File Interpreter ABI Platform
dirclass-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / dirclass-0.1.0.tar.gz

Download URL dirclass-0.1.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ae6e156dddb38d268cd7808378009513b0a6848594df63990022cd4ed8abcb0e
BLAKE2b-256 checksum
How to use checksums
e4f1ad00679b03f4e227a23e74e04dbb078e327c804bd68659081e35fa6dc137
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 14, 2025.

Transparency log

Release files / dirclass-0.1.0-py3-none-any.whl

Download URL dirclass-0.1.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20c4862d1e0e7a7e987f1b4646b11b250222265219cefed03151c67c423d6da8
BLAKE2b-256 checksum
How to use checksums
2d4f30a411fc46cf6a333953e0700170177890cd5a80f87783e488f64991a00e
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 14, 2025.

Transparency log

Security for dirclass 0.1.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 dirclass-0.1.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 14, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full 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