cape.cli: Other cape command-line interface functions

This module defines functions that do the work of auxiliary cape command-line interface commands such as

$ cape-expandjson
cape.cli.expand_json(*a, **kw)

Expand one or more JSON files

This function performs two tasks:

  • Removes comments starting with either '//' or '#'

  • Replaces JSONFile(fname) with the contents of fname

The comments are removed recursively, so comments within children files are allowed. If the output file is the same as the input file, the suffix .old is added to the original file, and the expanded contents are written to a new file with the same name as the input file.

Call:
>>> expand_json(ifile, ofile, **kw)
>>> expand_json(i=ifile, o=ofile, **kw)
Inputs:
ifile: str

Name of input file

ofile: str

Name of output file (default “file.json” -> “file.expanded.json”)

Versions:
  • 2015-10-27 @ddalle: v1.0

  • 2021-10-12 @ddalle: v2.0; single file

cape.cli.main_expandjson()

CLI for expand_json()

Call:
>>> main_expandjson()
Versions:
  • 2021-10-12 @ddalle: v1.0