CleverRaven/Cataclysm-DDA — pull request #9087 by jeremyosborne (2014-09-18 00:16:02+00:00)
Title: Json tools

Just an update, and finally the refactor I wanted to do to the internal code, of these json parsing scripts.

All scripts now use argparse. Get info with the -h flag.

`keys.py` is used to get the counts of keys used within a set of game data.

`values.py` is used to get a count of values used within a particular key within a set of game data.

`pluck.py` is used to grab entire json blobs from with a set of game data.

`splitter.py` is used to take a set of the game data files and split them into matched or not matched.

`lister.py` is a helper. pipe json objects or arrays to it, get a sorted list of keys back.

Examples:

# Anything of type dream and strength 2 goes to stdout
# everything else goes to stderr
./splitter.py --fnmatch=dreams.json type=dream strength=2 1>matched.json 2>not_matched.json

# What's the list of material on all the items (no counts, just the list of materials)
./values.py -k material | ./lister.py

# Display all of the keys used across all of the JSON files and how
# many times they occur.
./keys.py --human

# Just list the set of keys used across all of the json blobs.
./keys.py | ./lister.py --human

# List all of the json objects that are of type dream and have a strength of 2
./pluck.py --all type=dream strength=2

# List the very first item found in the stream of JSON data
# that is made of plastic and steel (not everday useful, but can be
# used to see if an item like this exists).
./pluck.py material=plastic material=steel