| 1267 | return decmsg |
| 1268 | |
| 1269 | def parse(self, packet): |
| 1270 | unarmored = self.ascii_unarmor(packet) |
| 1271 | data = unarmored['body'] |
| 1272 | |
| 1273 | if unarmored['magic'] is not None and unarmored['magic'] not in ['MESSAGE', 'SIGNATURE']: |
| 1274 | raise ValueError('Expected: MESSAGE. Got: {}'.format(str(unarmored['magic']))) |
| 1275 | |
| 1276 | if unarmored['headers'] is not None: |
| 1277 | self.ascii_headers = unarmored['headers'] |
| 1278 | |
| 1279 | # cleartext signature |
| 1280 | if unarmored['magic'] == 'SIGNATURE': |
| 1281 | # the composition for this will be the 'cleartext' as a str, |
| 1282 | # followed by one or more signatures (each one loaded into a PGPSignature) |
| 1283 | self |= self.dash_unescape(unarmored['cleartext']) |
| 1284 | while len(data) > 0: |
| 1285 | pkt = Packet(data) |
| 1286 | if not isinstance(pkt, Signature): # pragma: no cover |
| 1287 | warnings.warn("Discarded unexpected packet: {:s}".format(pkt.__class__.__name__), stacklevel=2) |
| 1288 | continue |
| 1289 | self |= PGPSignature() | pkt |
| 1290 | |
| 1291 | else: |
| 1292 | while len(data) > 0: |
| 1293 | self |= Packet(data) |
| 1294 | |
| 1295 | |
| 1296 | class PGPKey(Armorable, ParentRef, PGPObject): |