Skip to main content

Validate and optionally create directory structures from YAML or JSON schema files.

Project description

PyPI Downloads codecov

deardir

Validate and optionally create project directory structures from JSON or YAML schema files.

pypi ref: https://pypi.org/project/deardir/


➡️ Features

  • Validate file/folder structures using declarative schema files
  • Supports .json, .yaml, .yml, Python dict or list objects
  • Optionally auto-creates missing directories and files
  • Async live mode to continuously monitor a structure
  • Python API and CLI interface

➡️ Installation

pip install deardir

Or if you are developing locally:

poetry install

➡️ Example Schema

schema.yml

- data
- src:
    - __init__.py
    - main.py
    - utils:
        - helpers.py
- README.md
- pyproject.toml

➡️ Usage

Python

from deardir import DearDir
from pathlib import Path

dd = DearDir(root_paths=[Path(".")], schema=Path("schema.yml"))
dd.create_missing = True
dd.validate()

print(dd.missing)   # Set of missing paths
print(dd.created)   # Set of paths that were created

Async live mode

dd = DearDir([Path(".")], "schema.yml")
dd.create_missing = True

dd.live(interval=10, duration=60, mode=1)

# Thread
dd.live(interval=10, duration=60, mode=2)

# Synchron
dd.live(interval=10, duration=60, mode=0)

CLI

deardir
deardir --help
deardir check --help
deardir --version
deardir check ./Tests --schema schema.yaml 
deardir check ./Tests --schema schema.yaml --create
#ASYNC LIVE WATCHER:
deardir watch ./Tests --schema schema.yaml --create --interval 1 --duration 10

➡️ Future Ideas (help wanted!)

  • Improved CLI and JSON/HTML/Markdown reporting with colorized output
  • Support for optional files/folders and conditional rules in schema
  • Custom user-defined validation hooks
  • Auto-fix mode (e.g. create from templates, autofill missing entries)
  • File system watch mode with live validation (--watch)
  • GUI or web interface for drag-and-drop validation
  • GitHub Action / CI/CD integration
  • Multi-language support (English, German, ...)

📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deardir-0.1.4.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deardir-0.1.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file deardir-0.1.4.tar.gz.

File metadata

  • Download URL: deardir-0.1.4.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.11.0-1014-azure

File hashes

Hashes for deardir-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8dd1cb483b02ae0ce6475cdd28a593bebe91eaf268a8eecd45e701b158c3bbe2
MD5 331e855fa69faaa19bad6948a5afe7ab
BLAKE2b-256 e038ee2ae7656449f501a329643695df6d0f2036ac8ae0565887ba3f3b76fe36

See more details on using hashes here.

File details

Details for the file deardir-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: deardir-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.11.0-1014-azure

File hashes

Hashes for deardir-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 29e568027457a3d9eed41b9c6403c8cf0dd2f9011316ed7997717cef2b72aac9
MD5 b41900113f45ace489deed50e35c7cc2
BLAKE2b-256 f31499796dcb374c0a7b16073116a0ac5035027455c83eb23d349cdfdc49d6af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page