Anonymous Anonymous - 21 days ago
50 0

No description

Python

Summary

def summary(query_data_list):
    temp_data_list = []
    summary_source = ['Summary', 'N/A']
    temp_data = {}

    for source in query_data_list:
        temp_str = []
        malicious_entries = 0

        for key in source[2]: 
            if source[2][key][1] > 0:
                malicious_entries += source[2][key][1]
                temp_str.append((str(key), False))
                string_true = False

                for data in source[2][key][0]:
                    if data[1]:
                        string_true = True
                        temp_str.append(data)
                    elif '----' in data[0] and string_true:
                        temp_str.append(data)
                        string_true = False
                temp_str.append(('----------------------------------------------------', False))

        if malicious_entries > 0:
            if temp_str:
                temp_str.pop()
            temp_data[source[0]] = (temp_str, malicious_entries, malicious_entries)

    summary_source.append(temp_data)
    temp_data_list = [summary_source] + query_data_list
    return temp_data_list