Skip to main content

Linter to ensure a file/directory complies with a specified schema

Project description

Directory Schema Checker

https://img.shields.io/pypi/v/dirschema.svg https://img.shields.io/travis/mozbhearsum/dirschema.svg Documentation Status Updates

Linter to ensure a directory complies with a schema.

Quickstart

Define a schema:

{
    "allow_extra_files": true,
    "allow_extra_dirs": true,
    "files": {
        "HISTORY.rst": {},
        "MANIFEST.in": {
            "contains": [
                "include pyproject.toml",
                "include setup.py",
                "recursive-include src *",
                "recursive-include tests *"
            ]
        },
        "README.rst": {},
        "pyproject.toml": {},
        "setup.py": {},
        "tox.ini": {},
        ".taskcluster.yml": {}
    },
    "dirs": {
        "requirements": {
            "allow_extra_files": false,
            "allow_extra_dirs": false,
            "files": {
                "base.in": {},
                "base.txt": {},
                "test.in": {},
                "test.txt": {},
                "local.in": {},
                "local.txt": {}
            }
        },
        "src": {
            "allow_extra_files": false,
            "allow_extra_dirs": true
        },
        "tests": {
            "allow_extra_files": true,
            "allow_extra_dirs": true
        }
    }
}

Create a directory structure:

$ find sample/
sample
sample/HISTORY.rst
sample/src
sample/setup.py
sample/pyproject.toml
sample/requirements
sample/requirements/base.in
sample/requirements/local.txt
sample/requirements/base.txt
sample/requirements/local.in
sample/requirements/test.txt
sample/requirements/test.in
sample/MANIFEST.in
sample/.taskcluster.yml
sample/tox.ini
sample/README.rst
$ cat sample/MANIFEST.in
include pyproject.toml
include setup.py
recursive-include src *
$ dirschema sample.json sample/
Checking sample/…

Results
*******
sample/: Has errors
missing dir in root directory: tests
MANIFEST.in is missing required string: 'recursive-include tests *'

$

Fix the errors, and run it again:

$ echo "recursive-include tests *" >> sample/MANIFEST.in
$ mkdir sample/tests
$ dirschema sample.json sample/
Checking sample/…

Results
*******
sample/: Success!

$

Features

  • Require specified files to exist, and optionally have specific contents
  • Require specified directories to exist
  • Allow or deny files outside of the schema to exist
  • Directory structure can be checked as deep as desired
  • Check a local directory or a Github repository

FAQ

  • Why?
  • Why not JSON Schema?

Credits

History

0.1.0 (2019-10-30)

  • First release. Supports checking local filesystems as well as Github repositories.

Project details


Release history Release notifications

This version

0.5

Download files

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

Files for dirschema, version 0.5
Filename, size File type Python version Upload date Hashes
Filename, size dirschema-0.5-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size dirschema-0.5.tar.gz (17.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page