Exemple #1
0
 def test_repr(self):
     from klvdata.element import UnknownElement
     self.assertIsInstance(
         eval(
             repr(
                 UnknownElement(b'\x02',
                                b'\x00\x04\x60\x50\x58\x4E\x01\x80'))),
         UnknownElement)
Exemple #2
0
    def __next__(self):
        key, value = next(self.iter_stream)

        if key in self.parsers:
            return self.parsers[key](value)
        else:
            # Even if KLV is not known, make best effort to parse and preserve.
            # Element is an abstract super class, do not create instances on Element.
            return UnknownElement(key, value)
Exemple #3
0
 def __next__(self):
     key, value = next(self.iter_stream)
     #         qgsu.showUserAndLogMessage(
     #              "", "Streamparser key: " + str(key) + " value: " + str(value), onlyLog=True)
     if key in self.parsers:
         return self.parsers[key](value)
     else:
         # Even if KLV is not known, make best effort to parse and preserve.
         # Element is an abstract super class, do not create instances on
         # Element.
         return UnknownElement(key, value)
Exemple #4
0
    def test_str(self):
        from klvdata.element import UnknownElement

        self.assertEqual(
            str(UnknownElement(b'\x02', b'\x00\x04\x60\x50\x58\x4E\x01\x80')),
            "UnknownElement: (b'\\x02', 8, b'\\x00\\x04`PXN\\x01\\x80')")
Exemple #5
0
 def test_name(self):
     from klvdata.element import UnknownElement
     self.assertEqual(
         UnknownElement(b'\x02', b'\x00\x04\x60\x50\x58\x4E\x01\x80').name,
         "UnknownElement")
Exemple #6
0
 def test_packet(self):
     from klvdata.element import UnknownElement
     self.assertEqual(
         bytes(UnknownElement(b'\x02',
                              b'\x00\x04\x60\x50\x58\x4E\x01\x80')),
         b'\x02\x08\x00\x04\x60\x50\x58\x4E\x01\x80')
Exemple #7
0
 def test_length(self):
     from klvdata.element import UnknownElement
     self.assertEqual(
         UnknownElement(b'\x02',
                        b'\x00\x04\x60\x50\x58\x4E\x01\x80').length,
         b'\x08')