def write_yaml_report(func):
    """Decorator used in campaign node post-processing
    """

    @wraps(func)
    def _wrapper(*args, **kwargs):
        now = datetime.datetime.now()
        with Timer() as timer:
            data = func(*args, **kwargs)
            if isinstance(data, (SEQUENCES, types.GeneratorType)):
                report = dict(children=list(map(str, data)))
            elif isinstance(data, MAPPINGS):
                report = data
            else:
                raise Exception('Unexpected data type: %s', type(data))
        report['elapsed'] = timer.elapsed
        report['date'] = now.isoformat()
        if "no_exec" not in kwargs and report is not None:
            with open(YAML_REPORT_FILE, 'w') as ostr:
                yaml.dump(report, ostr, default_flow_style=False)
        return report

    return _wrapper
def write_yaml_report ( func ) : @ wraps ( func ) def _wrapper ( * args , ** kwargs ) : now = datetime . datetime . now ( ) with Timer ( ) as timer : data = func ( * args , ** kwargs ) if isinstance ( data , ( SEQUENCES , types . GeneratorType ) ) : report = dict ( children = list ( map ( str , data ) ) ) elif isinstance ( data , MAPPINGS ) : report = data else : raise Exception ( 'Unexpected data type: %s' , type ( data ) ) report [ 'elapsed' ] = timer . elapsed report [ 'date' ] = now . isoformat ( ) if "no_exec" not in kwargs and report is not None : with open ( YAML_REPORT_FILE , 'w' ) as ostr : yaml . dump ( report , ostr , default_flow_style = False ) return report return _wrapper
Decorator used in campaign node post-processing