pass
+def packets_from_bytes(data):
+ offset = 0
+ while offset < len(data):
+ packet = PGPPacket()
+ offset += packet.from_bytes(data=data[offset:])
+ yield packet
+
+
def migrate(old_key, new_key):
"""Add the old key and sub-keys to the new key
"""
old_key_export = _get_stdout(
['gpg', '--export', old_key])
- old_key_packet = PGPPacket()
- old_key_packet.from_bytes(data=old_key_export)
+ old_key_packets = list(
+ packets_from_bytes(data=old_key_export))
old_key_secret_export = _get_stdout(
['gpg', '--export-secret-keys', old_key])
- old_key_secret_packet = PGPPacket()
- old_key_secret_packet.from_bytes(data=old_key_secret_export)
+ old_key_secret_packets = list(
+ packets_from_bytes(data=old_key_secret_export))
import pprint
- pprint.pprint(old_key_packet)
- pprint.pprint(old_key_secret_packet)
+ pprint.pprint(old_key_packets)
+ pprint.pprint(old_key_secret_packets)
if __name__ == '__main__':