import json


def get_threshold(filename, current_threshold, service, version):
    """
    Get the threshold score
    :param filename: String, File that containes the best score. Ie, './path/file.py'
    :param current_threshold: Float, the latest score. Ie, 6.78
    :param service: String, Service to evaluate. Ie, 'originationservice'
    :param version: String, Python version to test. Ie, 'python_3'
    :return: Float, The last score to evaluate. Ie, 7.89
    """
    try:
        with open(filename) as f:
            file_data = f.read()
        file_object = json.loads(file_data)
    except:
        file_object = {}

    try:
        threshold = file_object[version][service]
    except:
        threshold = current_threshold

    return file_object, threshold