def extract_changelogs_from_a_history_entry(out_changes, history_entry, change_num, record_name=None, record_type=None):
    if (history_entry.detail is None):
        return
    if ('add_rrests' in history_entry.detail):
        detail_dict = json.loads(history_entry.detail)
    else:
        return
    add_rrests = detail_dict['add_rrests']
    del_rrests = detail_dict['del_rrests']
    for add_rrest in add_rrests:
        exists = False
        for del_rrest in del_rrests:
            if ((del_rrest['name'] == add_rrest['name']) and (del_rrest['type'] == add_rrest['type'])):
                exists = True
                if (change_num not in out_changes):
                    out_changes[change_num] = []
                out_changes[change_num].append(HistoryRecordEntry(history_entry, del_rrest, add_rrest, '*'))
                break
        if (not exists):
            if (change_num not in out_changes):
                out_changes[change_num] = []
            out_changes[change_num].append(HistoryRecordEntry(history_entry, [], add_rrest, '+'))
    for del_rrest in del_rrests:
        exists = False
        for add_rrest in add_rrests:
            if ((del_rrest['name'] == add_rrest['name']) and (del_rrest['type'] == add_rrest['type'])):
                exists = True
                break
        if (not exists):
            if (change_num not in out_changes):
                out_changes[change_num] = []
            out_changes[change_num].append(HistoryRecordEntry(history_entry, del_rrest, [], '-'))
    if ((record_name != None) and (record_type != None)):
        if (change_num in out_changes):
            changes_i = out_changes[change_num]
        else:
            return
        for hre in changes_i:
            if (('type' in hre.add_rrest) and (hre.add_rrest['name'] == record_name) and (hre.add_rrest['type'] == record_type)):
                continue
            elif (('type' in hre.del_rrest) and (hre.del_rrest['name'] == record_name) and (hre.del_rrest['type'] == record_type)):
                continue
            else:
                out_changes[change_num].remove(hre)
def extract_changelogs_from_a_history_entry(out_changes, history_entry, change_num, record_name=None, record_type=None):
    if (history_entry.detail is None):
        return
    if ('add_rrests' in history_entry.detail):
        detail_dict = json.loads(history_entry.detail)
    else:
        return
    add_rrests = detail_dict['add_rrests']
    del_rrests = detail_dict['del_rrests']
    for add_rrest in add_rrests:
        exists = False
        for del_rrest in del_rrests:
            if ((del_rrest['name'] == add_rrest['name']) and (del_rrest['type'] == add_rrest['type'])):
                exists = True
                if (change_num not in out_changes):
                    out_changes[change_num] = []
                out_changes[change_num].append(HistoryRecordEntry(history_entry, del_rrest, add_rrest, '*'))
                break
        if (not exists):
            if (change_num not in out_changes):
                out_changes[change_num] = []
            out_changes[change_num].append(HistoryRecordEntry(history_entry, [], add_rrest, '+'))
    for del_rrest in del_rrests:
        exists = False
        for add_rrest in add_rrests:
            if ((del_rrest['name'] == add_rrest['name']) and (del_rrest['type'] == add_rrest['type'])):
                exists = True
                break
        if (not exists):
            if (change_num not in out_changes):
                out_changes[change_num] = []
            out_changes[change_num].append(HistoryRecordEntry(history_entry, del_rrest, [], '-'))
    if ((record_name != None) and (record_type != None)):
        if (change_num in out_changes):
            changes_i = out_changes[change_num]
        else:
            return
        for hre in changes_i:
            if (('type' in hre.add_rrest) and (hre.add_rrest['name'] == record_name) and (hre.add_rrest['type'] == record_type)):
                continue
            elif (('type' in hre.del_rrest) and (hre.del_rrest['name'] == record_name) and (hre.del_rrest['type'] == record_type)):
                continue
            else:
                out_changes[change_num].remove(hre)