@staticmethod
    def parse(line):
        '''
        parse(line)

        Parses a string representing a NMEA 0183 sentence, and returns a
        NMEASentence object

        Raises ValueError if the string could not be parsed, or if the checksum
        did not match.
        '''
        match = NMEASentence.sentence_re.match(line)
        if not match:
            raise ParseError('could not parse data: %r' % line)

        # pylint: disable=bad-whitespace
        nmea_str        = match.group('nmea_str')
        data_str        = match.group('data')
        checksum        = match.group('checksum')
        sentence_type   = match.group('sentence_type').upper()
        data            = data_str.split(',')

        if checksum:
            cs1 = int(checksum, 16)
            cs2 = NMEASentence.checksum(nmea_str)
            if cs1 != cs2:
                raise ChecksumError(
                    (cs1, cs2) % 'checksum does not match: %02X != %02X')

        talker_match = NMEASentence.talker_re.match(sentence_type)
        if talker_match:
            talker = talker_match.group('talker')
            sentence = talker_match.group('sentence')
            cls = TalkerSentence.sentence_types.get(sentence)

            if not cls:
                # TODO instantiate base type instead of fail
                raise SentenceTypeError('Unknown sentence type %s' % sentence_type)
            return cls(talker, sentence, data)

        query_match = NMEASentence.query_re.match(sentence_type)
        if query_match and not data_str:
            talker = query_match.group('talker')
            listener = query_match.group('listener')
            sentence = query_match.group('sentence')
            return QuerySentence(talker, listener, sentence)

        proprietary_match = NMEASentence.proprietary_re.match(sentence_type)
        if proprietary_match:
            manufacturer = proprietary_match.group('manufacturer')
            cls = ProprietarySentence.sentence_types.get(manufacturer, ProprietarySentence)
            return cls(manufacturer, data)

        raise ParseError('could not parse sentence type: %r' % sentence_type)
dataset/ETHPy150Open Knio/pynmea2/pynmea2/nmea.py/NMEASentence.parse/swapped operands of `%`