def endpoint_events_extraction()

in scripts/qlog_parser.py [0:0]


def endpoint_events_extraction(file_name, vantagepoint):
    assert(vantagepoint == "server" or vantagepoint == "client")
    conn_events = {
        "vantage_point" :  {"name": vantagepoint + "-view",
                             "type": vantagepoint
        },
        "title": "xquic qlog", 
        "description": "",
        "common_fields": { "ODCID": "", "time_format": "absolute" },
        "events": []
    }
    count = 0
    last_scid_ = "initcid"
    traces_log = {}
    with open(file_name, 'r',encoding='utf-8', errors='ignore') as file:
        for line in file:
            event, scid = parse_line(line)
            if (event is None):
                continue
            if (event is not None) and (scid != last_scid_):
                if count > 0:
                    if(scid in traces_log):
                        traces_log[scid]['events'] += conn_events['events']
                    else:
                        traces_log[last_scid_] = conn_events
                last_scid_ = scid
                conn_events = {
                    "title": "xquic-qlog json: " + vantagepoint, 
                    "description": "",
                    "common_fields": { "ODCID": scid, "time_format": "absolute" },
                    "vantage_point" :  {"name": vantagepoint + "-view",
                             "type": vantagepoint
                    },
                    "events": []
                }
                count = 1
                conn_events["events"].append(event)
            else:
                count += 1
                conn_events["events"].append(event)
    if(count > 1):
        scid = conn_events["common_fields"]["ODCID"]
        if(scid in traces_log):
            traces_log[scid]['events'] += conn_events['events']
        else:
            traces_log[scid] = conn_events
    return list(traces_log.values())