diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-12-27 16:46:08 +0900 |
commit | db20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch) | |
tree | e5435159cd1bf0519276363a6fe1663d1721bed3 /extract-from-json.py | |
parent | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff) | |
download | coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2 coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip |
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'extract-from-json.py')
-rwxr-xr-x | extract-from-json.py | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/extract-from-json.py b/extract-from-json.py deleted file mode 100755 index e432b2b067..0000000000 --- a/extract-from-json.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python - -import argparse -import json -import sys - -def parse_args(): - parser = argparse.ArgumentParser( - description="""Extracts information from a json file by navigating the JSON object using a - sequence of property accessors and returning the JSON subtree, or the raw data, found - at that location.""" - ) - - parser.add_argument( - '-f', '--file', - metavar='<project.json>', - help="Path to project.json file to parse", - required=True, - ) - - parser.add_argument( - 'property', - metavar='property_name', - help="""Name of property to extract using object notation. - Pass multiple values to drill down into nested objects (in order).""", - nargs='*', - ) - - parser.add_argument( - '-r', '--raw', - help="""Dumps the raw object found at the requested location. - If omitted, returns a JSON formatted object instead.""", - action='store_true', - default=False - ) - - return parser.parse_args() - -def main(): - args = parse_args() - - with open(args.file) as json_file: - selected_property = json.load(json_file) - - for prop in args.property: - selected_property = selected_property[prop] - - if args.raw: - print(selected_property) - else: - print(json.dumps(selected_property)) - - return 0 - -if __name__ == "__main__": - sys.exit(main()) |