Parses the provided filename and returns ``SettingParser`` if the
        parsing was successful and header matches the header defined in the
        file.

        Returns ``SettingParser`` instance.

        * Raises a ``ParseError`` exception if header doesn't match or parsing
          fails.

def parse_config(filename, header):
    """ Parses the provided filename and returns ``SettingParser`` if the
        parsing was successful and header matches the header defined in the
        file.

        Returns ``SettingParser`` instance.

        * Raises a ``ParseError`` exception if header doesn't match or parsing
          fails.
        """

    parser = SettingParser(filename)
    if parser.header != header:
        header_value = parser.header or ''
        raise ParseError(u"Unexpected header '{0}', expecting '{1}'"
                         .format(common.from_utf8(header_value), header))

    return parser