if self['unhashed-subpackets']:
lines.append(' unhashed subpackets:')
for subpacket in self['unhashed-subpackets']:
- lines.append(' {}'.format(subpacket['type']))
+ method_name = '_str_{}_signature_subpacket'.format(
+ self._clean_type(type=subpacket['type']))
+ method = getattr(self, method_name, None)
+ if method:
+ lines.append(' {}: {}'.format(
+ subpacket['type'],
+ method(subpacket=subpacket)))
+ else:
+ lines.append(' {}'.format(subpacket['type']))
return '\n'.join(lines)
def _str_user_id_packet(self):
offset += 4
subpacket['type'] = self._signature_subpacket_types[data[offset]]
offset += 1
- subpacket['data'] = data[offset: offset + length - 1]
- offset += len(subpacket['data'])
+ subpacket_data = data[offset: offset + length - 1]
+ offset += len(subpacket_data)
+ method_name = '_parse_{}_signature_subpacket'.format(
+ self._clean_type(type=subpacket['type']))
+ method = getattr(self, method_name, None)
+ if not method:
+ raise NotImplementedError(
+ 'cannot parse signature subpacket type {!r}'.format(
+ subpacket['type']))
+ method(data=subpacket_data, subpacket=subpacket)
return (offset, subpacket)
def _parse_signature_packet(self, data):