#!python

usage = """
Gizmo for examining a JSON encoded data structure

Script usage:

$ json_gizmo JSON_FILE_PATH
"""

try:
    import sys
    import os
    import json
    from H5Gizmos.python.examine import examine
    import H5Gizmos as gz
    [path] = sys.argv[1:]
    path = os.path.expanduser(path)
    print ("attempting to parse JSON in", repr(path))
    file = open(path)
    obj = json.load(file)
    gz.serve(examine(obj))
except Exception as e:
    print("Exception", e)
    print(usage)
    raise
