def trace_output(lines, index, end): cont = False seq = [] _cls = None _data = [] _sent = {} _recv = {} phase = "" while index < end: line = lines[index] if cont: if line == "}": _data.append(line) cont = False _args = json.loads("".join(_data)) if _cls == "JWKS": try: _inst = jwks_load("".join(_data)) except TypeError: pass elif _cls == "UserInfo": _int = Message(**_args) try: _inst = OpenIDSchema(**_int["claims"]) except KeyError: _inst = OpenIDSchema(**_args) else: try: _inst.jwe_header = _int["jwe header parameters"] except KeyError: pass try: _inst.jws_header = _int["jws header parameters"] except KeyError: pass else: try: _inst = oic_factory(_cls)(**_args) except KeyError: _inst = oauth2_factory(_cls)(**args) seq.append((_cls, _inst)) else: _data.append(line) index += 1 continue if line == DIV: break elif line == "Trace output" or line == "": pass else: for phase in ORDER: m = PATTERN[phase].match(line) if m: if phase == "head": seq.append(m.groups()[0]) elif phase == "sent": key, val = m.groups() _sent[key] = val elif phase == "recv": key, val = m.groups() _recv[key] = val elif phase == "quer": _recv["QUERY"] = m.groups()[0] phase = "recv" elif phase == "data": m = DATA.match(line) cont = True _cls = m.groups()[0] _data = ['{'] elif phase == "tag": seq.append(("info", m.groups()[0])) if phase in ["head", "data", "end"]: if _sent: seq.append(("sent", _sent)) _sent = {} if _recv: seq.append(("recv", _recv)) _recv = {} break if phase == "end": break index += 1 return index, seq