imagedex

Created: 2011-07-19 01:02
Updated: 2013-12-14 02:46

readme.md

Generate a JSON representation of a given directory listing, like so:

$ imagedex -r -P repo ./ | python -mjson.tool
{
    "repo": [
        "./.gitignore",
        "./imagedex.py",
        "./readme.md",
        {
            ".git": [
                "./.git/packed-refs",
                "./.git/FETCH_HEAD",
                "./.git/description",
                "./.git/ORIG_HEAD",
                "./.git/COMMIT_EDITMSG",
                "./.git/HEAD",
                "./.git/index",
                "./.git/config"
            ]
        },
        {
            "imagedex": [
                "./imagedex/__init__.py",
                "./imagedex/__init__.pyc"
            ]
        }
    ]
}

Almost everything about the output is configurable via command line options.

$ imagedex -j jsonPcallBack -P repo ./ | python -mjson.tool
jsonPcallBack({
    "repo": [
        / * ... */
    ]
})

#Use: To see all available flags and options, run: imagedex.py -h

I run this script as a response to inotify events; only generating a .json file when something in the target directory supposedly changes. For a live example, see api_drawings script I run on my web server:

while inotifywait --excludei='.*.swp' -r -e modify /some/dir/; do
    imagedex -r -j callBack -p '/api/3/' -f /api/path/imagedex.json /some/dir
done

##TODO:

  • Write proper unit tests for all our little quirks

##Notes:

  • Be aware that the -r recursive option is a lie and only provides data for a single directory level down.
  • As this script is just a wrapper around the python module, simplejson it must be installed.
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more