Source code for emod_api.config.dtk_post_process_adhocevents

#!/usr/bin/python
import json
import os

def _recursive_json( ref_json, flat_input_json ):
    for val in ref_json:
        #if not leaf, call recursive_json_leaf_reader
        if isinstance( ref_json[val], dict ):
            _recursive_json( ref_json[val], flat_input_json ) 
        else:
            if val not in flat_input_json:
                flat_input_json[val] = ref_json[val]

[docs]def application( output_path ): print( "DTK POST PROC SCRIPT: Convert all GPIO_X labels in output files." ) if os.path.exists( "config_xform.json" ) == False: # nothing to be done. return config_json = json.loads( open( "config_xform.json" ).read() ) event_map = config_json["parameters"]["Event_Map"] for filename in os.listdir( output_path ): if filename.endswith( ".json" ) or filename.endswith( ".csv" ): lines = [] with open( os.path.join( output_path, filename ) ) as report_in: for line in report_in: for event in event_map: line = line.replace( event, event_map[ event ] ) lines.append( line ) with open( os.path.join( output_path, filename ), "w" ) as report_out: for line in lines: report_out.write( line ) return "blah"