import re


def get_abc_score(result, method):
    """
        Get ABC score from a method
    """

    result = re.split(r'\* Line  |\* Line ', result)

    for line in result:
        if method.class_name + "#" in line:
            # print('ENTROU')
            name = line.split(method.class_name + "#")[1].split(' ')[0].replace(' ', '')
            # print('name: ', name)
            if name == method.method_name:
                if 'abc score of ' in line:
                    abc = line.split('abc score of ')[1]
                    abc = re.findall("\\d+\\.\\d+", abc)
                    if len(abc) > 0:
                        return float(abc[0])
    return 0