README
SUMMARY
ndexr -- Tool to use from Python interactive interpreter or script. Use it to make JSON indexes
of all files in a directory, or files of a certain type. Could be used to observe activity in a
server directory and save logs elsewhere for an administrator or another script to use. Or to
generate JSON to send to clients searching remotely. Or to keep an index of files in a directory
when the user of that directory does not have permission to probe the files system for files
without knowing their names. Uses a configuration file, or optionally you can pass configuration
information as keyword arguments.
INSTALLATION (optional):
cd /path/to/ndexr
python setup.py install
USEAGE
from python interpreter...
>>> import ndexr, os
>>> myindexer = ndexr.Ndexr()
>>> myindexer.write_index(cfg="ndexr-config.json")
wrote 2 filenames to /Users/rab/Desktop/_test_index_few.json
>>> myindexer.write_index(cfg="ndexr-some-other-config.json")
wrote 10 filenames to /Users/rab/Desktop/_test_index.json
or from file (edit the config files first)…
cd /path/to/module/
python example.py
Recursive example:
>>> import ndexr
>>> myindexer = ndexr.Ndexr()
>>> for root, dirs, files in os.walk('/Users/rab/code/monster_corona/parts/'):
. . . myindexer.write_index(in_directory=root, out_file=root + "/_index.json")
. . . <Enter>
wrote 1 filenames to /Users/rab/code/monster_corona/parts//_index.json
wrote 5 filenames to /Users/rab/code/monster_corona/parts/body/_index.json
wrote 7 filenames to /Users/rab/code/monster_corona/parts/head/_index.json
<et cetera>
(see also recursive_example.py)
PURPOSE
Developer tool to index files such as art sources so that an application can find them. Some
environments don't allow probing the file system, so you must know the names of all files in the
directory. Having an index file with a known filename solves this problem. The same tool can be
adapted to allow users to index a group of files, then drop them into a directory with the index.
That solves the problem of users adding files without using your application, when your
application can not probe for files without knowing their names.
OTHER USES
Maybe it would be handy for returning a JSON representation of a directory to clients as part of
a web service. Or for posting an index of your music?