import inspect
import re


def getExPat(in_content):
    """
    Get exam pattern from the file. Only handles 2012 and 2008 format
    files.
    """

    err_msg = ("%s expected argument of type 'list'; %s given" %
                (inspect.stack()[0][3], type(in_content)))
    assert (type(in_content) is list), err_msg

    patCom_re = r'.*PUNE.*\(([0-9]{4})\s*[A-Z\.]+\).*'
    pat = 'UNKN'

    for line in in_content:
        line = line.strip()
        ret_obj = re.match(patCom_re, line)
        if ret_obj:
            pat = ret_obj.group(1)
            break

    # Only expected values be returned
    if pat.strip() in ('2008', '2012'):
        return pat.strip()
    else:
        return 'UNKN'