def import_from_gpg(self):
key_export = _get_stdout(
['gpg', '--export', self.fingerprint])
- self.public_packets = list(
- self._packets_from_bytes(data=key_export))
+ self.public_packets = []
+ self._packets_from_bytes(list=self.public_packets, data=key_export)
if self.public_packets[0]['type'] != 'public-key packet':
raise ValueError(
'{} does not start with a public-key packet'.format(
self.fingerprint))
key_secret_export = _get_stdout(
['gpg', '--export-secret-keys', self.fingerprint])
- self.secret_packets = list(
- self._packets_from_bytes(data=key_secret_export))
+ self.secret_packets = []
+ self._packets_from_bytes(list=self.secret_packets, data=key_secret_export)
if self.secret_packets[0]['type'] != 'secret-key packet':
raise ValueError(
'{} does not start with a secret-key packet'.format(
for packet in self.public_packets + self.secret_packets:
packet.check_roundtrip()
- def _packets_from_bytes(self, data):
+ def _packets_from_bytes(self, list, data):
offset = 0
while offset < len(data):
packet = PGPPacket(key=self)
offset += packet.from_bytes(data=data[offset:])
- yield packet
+ list.append(packet)
def export_to_gpg(self):
raise NotImplemetedError('export to gpg')