def parse(self): """Parse the parent into items. Called on init and modification of parent value. If a known parser is not available for key, parse as generic KLV element. """ for key, value in KLVParser(self.value, self.key_length): try: self.items[key] = self.parsers[key](value) except KeyError: self.items[key] = self._unknown_element(key, value)
def parse(self): """Parse the parent into items. Called on init and modification of parent value. If a known parser is not available for key, parse as generic KLV element. """ for key, value in KLVParser(self.value, self.key_length): try: self.items[key] = self.parsers[key](value) except Exception: # None qgsu.showUserAndLogMessage("", "Value cannot be read for key: " + str(key.hex()), onlyLog=True)
def parse(self): """Parse the parent into items. Called on init and modification of parent value. If a known parser is not available for key, parse as generic KLV element. """ for key, value in KLVParser(self.value, self.key_length): try: self.items[key] = self.parsers[key](value) except (KeyError, TypeError, ValueError): self.items[key] = self._unknown_element(key, value) except Exception: # None qgsu.showUserAndLogMessage( "", "Value cannot be read for Tag: " + str(int.from_bytes(key, byteorder=sys.byteorder)) + " value: " + str(value), onlyLog=True)
def __init__(self, source): self.source = source # All keys in parser are expected to be 16 bytes long. self.iter_stream = KLVParser(self.source, key_length=16)