Giter VIP home page Giter VIP logo

filemarx's Introduction

filemarx

A tool to check that a directory structure conforms to a given JSON Schema.

In case of check failure, following actions can be taken, depending on your configuration:

  • Output defects to the console
  • Send a file listing all defects to a Slack conference room

Installation

Using pip should suffice

pip install filemarx

Configuration

You have to produce a JSON Schema file against which your directory's structure will be validated. An example of this can be found in the samples/design.json file.

Let's say that your file structure is this:

./anotherfile
./file1
./somedir
./somedir/andanother
./somedir/andanother/someotherfile
./somedir/somefilehere
./somedir/anotherdir
./file2

Then the produced JSON would be

{
    "files":[
        "anotherfile",
        "file1",
        "file2"
    ],
    "dirs":{
        "somedir":{
            "files":[
                "somefilehere"
            ],
            "dirs":{
                "anotherdir":{
                    "files":[
                    ],
                    "dirs":{
                    }
                },
                "andanother":{
                    "files":[
                        "someotherfile"
                    ],
                    "dirs":{
                    }
                }
            }
        }
    }
}

Usage

The command takes 3 mandatory positional arguments:

  1. Check name (to be set arbitrarily)
  2. Schema file location
  3. Directory to be checked

Example

filemarx Design samples/design.json /home/myself/designs

State-keeping options

If you run filemarx in a cron but you don't want errors to come up every minute, you can ignore them for X seconds once discovered. This can be done with a combination of options -t which sets a timeout (in seconds) and -s which indicate where to store the state file.

# Only pop errors every hour
filemarx -t 3600 -s /tmp/design_state.json Design samples/design.json /home/myself/designs

Pushing results to Slack

filemarx can connect to the Slack API in order to push errors to a given Slack channel. In order to do that, you need to get an API Token, then use options --slack-token and --slack-channels.

# Send it all to Slack
filemarx --slack-token 'get-your-own' --slack-channels '#general,#design' -t 3600 -s /tmp/design_state.json Design samples/design.json /home/myself/designs

filemarx's People

Contributors

xowap avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.