import re


def calculate_count(expr, codelines):
    """ Calculates occurrences of expr in codelines. (max 1/line) """

    count = 0
    for l in codelines:
        if re.match(expr, l) is not None:
            count +=1

    return count