<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_license(filename, **kwargs):
 """Perform a license check on the given file. The license format should be commented using # and live at the top of the file. Also, the year should be the current one. :param filename: path of file to check. :type filename: str :param year: default current year :type year: int :param ignore: codes to ignore, e.g. ``('L100', 'L101')`` :type ignore: `list` :param python_style: False for JavaScript or CSS files :type python_style: bool :return: errors :rtype: `list` """

    year = kwargs.pop("year", datetime.now().year)
    python_style = kwargs.pop("python_style", True)
    ignores = kwargs.get("ignore")
    template = "{0}: {1} {2}"

    if python_style:
        re_comment = re.compile(r"^#.*|\{#.*|[\r\n]+$")
        starter = "# "
    else:
        re_comment = re.compile(r"^/\*.*| \*.*|[\r\n]+$")
        starter = " *"

    errors = []
    lines = []
    file_is_empty = False
    license = ""
    lineno = 0
    try:
        with codecs.open(filename, "r", "utf-8") as fp:
            line = fp.readline()
            blocks = []
            while re_comment.match(line):
                if line.startswith(starter):
                    line = line[len(starter):].lstrip()
                    blocks.append(line)
                    lines.append((lineno, line.strip()))
                lineno, line = lineno + 1, fp.readline()
            file_is_empty = line == ""
            license = "".join(blocks)
    except UnicodeDecodeError:
        errors.append((lineno + 1, "L190", "utf-8"))
        license = ""

    if file_is_empty and not license.strip():
        return errors

    match_year = _re_copyright_year.search(license)
    if match_year is None:
        errors.append((lineno + 1, "L101"))
    elif int(match_year.group("year")) != year:
        theline = match_year.group(0)
        lno = lineno
        for no, l in lines:
            if theline.strip() == l:
                lno = no
                break
        errors.append((lno + 1, "L102", year, match_year.group("year")))
    else:
        program_match = _re_program.search(license)
        program_2_match = _re_program_2.search(license)
        program_3_match = _re_program_3.search(license)
        if program_match is None:
            errors.append((lineno, "L100"))
        elif (program_2_match is None or
              program_3_match is None or
              (program_match.group("program").upper() !=
               program_2_match.group("program").upper() !=
               program_3_match.group("program").upper())):
            errors.append((lineno, "L103"))

    def _format_error(lineno, code, *args):
        return template.format(lineno, code,
                               _licenses_codes[code].format(*args))

    def _filter_codes(error):
        if not ignores or error[1] not in ignores:
            return error

    return list(map(lambda x: _format_error(*x),
                    filter(_filter_codes, errors)))