File: adios2_json_pp.py

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 33,764 kB
  • sloc: cpp: 175,964; ansic: 160,510; f90: 14,630; yacc: 12,668; python: 7,275; perl: 7,126; sh: 2,825; lisp: 1,106; xml: 1,049; makefile: 579; lex: 557
file content (32 lines) | stat: -rwxr-xr-x 750 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
import json
import argparse
from os.path import exists


def SetupArgs():
    parser = argparse.ArgumentParser()
    parser.add_argument("--indent", "-i", type=int, default=2,
                        help="indent size, default=2")
    parser.add_argument("FILE", help="Name of the JSON file")
    args = parser.parse_args()

    # print(args)
    return args


def CheckFileName(args):
    if not exists(args.FILE):
        print("ERROR: File " + args.FILE + " does not exist", flush=True)
        exit(1)


if __name__ == "__main__":

    args = SetupArgs()
    CheckFileName(args)

    with open(args.FILE) as jsonfile:
        parsed = json.load(jsonfile)

    print(json.dumps(parsed, indent=args.indent, sort_keys=False))