<commit_before>#! /usr/local/bin/python3
import json
import sys
import pickle
import os
import time

def loadReport(fileJSON):
    # print ("fileJSON " + os.getcwd()+fileJSON)

    try:
        with open(os.getcwd() + fileJSON) as data_file:
            data = json.load(data_file)
            # print("FILE GOOD")
            return data
    # except EnvironmentError:
    except IOError:
        print("BAD FILE")
        return {}

def getTestsReport(reports):
    result = []
    i = 0
    while i < len(reports):
        report = loadReport(data["reports"][i]["report_json"])
        if len(report) == 0:
            i += 1
            continue
        test_report = {"type": data["reports"][i]["type"],
                "report": data["reports"][i]["report_html"]}
        test_report.update(report[data["reports"][i]["summary"]])
        result.append(test_report)
        i += 1
    return result<commit_msg>Fixed bug with exception if json-file does not contain json-object<commit_after>#! /usr/local/bin/python3
import json
import sys
import pickle
import os
import time

def loadReport(fileJSON):
    # print ("fileJSON " + os.getcwd()+fileJSON)

    try:
        with open(os.getcwd() + fileJSON) as data_file:
            data = json.load(data_file)
            return data
    # except EnvironmentError:
    except ValueError:
        print("BAD JSON")
        return {}
    except IOError:
        print("BAD FILE")
        return {}

def getTestsReport(reports):
    result = []
    i = 0
    while i < len(reports):
        report = loadReport(data["reports"][i]["report_json"])
        if len(report) == 0:
            i += 1
            continue
        test_report = {"type": data["reports"][i]["type"],
                "report": data["reports"][i]["report_html"]}
        test_report.update(report[data["reports"][i]["summary"]])
        result.append(test_report)
        i += 1
    return result
{'fraction_non_alphanumeric': 0.1366718831507564, 'fraction_numerical': 0.005216484089723527, 'mean_word_length': 2.3946902654867257, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4409779', 'n_tokens_mistral': 601, 'n_tokens_neox': 576, 'n_words': 137}