def mdm_formatter(results, verbose): """Convert Message Data Model into human-readable text.""" gron_output = gron.gron(json.dumps(results)) gron_output = gron_output.replace('json = {}', 'message_data_model = {}') gron_output = re.sub(r'\njson\.', '\n', gron_output) return gron_output
def test_ugly(): with open('./tests/data/ugly.json', 'r') as fh: IN = fh.read().strip() with open('./tests/data/ugly.gron', 'r') as fh: OUT = fh.read().strip() out = gron(IN) assert out == OUT
def test_github_data(): with open('./tests/data/github.json', 'r') as fh: IN = fh.read().strip() with open('./tests/data/github.gron', 'r') as fh: OUT = fh.read().strip() out = gron(IN) assert out == OUT
def main(): """Gron's CLI This method reads the arguments for the command line interface and runs `gron`. """ args = parser.parse_args() data = args.file.read() print(gron(data))
import flated_master import sys from distutils.util import strtobool import ast import os def err(message): print(message, file=sys.stderr) exit(1) argv = sys.argv typedef_struct_json = flated_master.get_typedef_struct_json('../out/Const.h') flated_master_list = gron(typedef_struct_json) params_type_dict = {} for line in flated_master_list: splited_line = line.split(' = ') params_name, params_data_type = splited_line[0], splited_line[1].replace( '"', '') params_type_dict[params_name] = params_data_type if (len(argv) == 2 and argv[1] == 'template'): params_template = [] # '文字 #' を使うときは気をつける for _, (params_name, params_data_type) in enumerate(params_type_dict.items()): if params_data_type == 'uint8_t': params_template.append('{} = {} // {}'.format( params_name, 0,