|
@@ -4,6 +4,7 @@ import typing
|
|
|
|
|
|
import numpy
|
|
|
import pandas
|
|
|
+import pgpdump
|
|
|
import scipy.io.wavfile
|
|
|
import sympy
|
|
|
import yaml
|
|
@@ -24,6 +25,19 @@ def numpy_array_from_file(
|
|
|
return numpy.frombuffer(path.read_bytes(), dtype=dtype)
|
|
|
|
|
|
|
|
|
+def split_pgp_file(
|
|
|
+ path: pathlib.Path,
|
|
|
+) -> typing.Iterator[typing.Union[bytearray, pgpdump.packet.Packet]]:
|
|
|
+ bundle = pgpdump.BinaryData(path.read_bytes())
|
|
|
+ remaining_bytes = bundle.data
|
|
|
+ for packet in bundle.packets():
|
|
|
+ prefix, remaining_bytes = remaining_bytes.split(packet.data, maxsplit=1)
|
|
|
+
|
|
|
+ yield prefix
|
|
|
+ yield packet
|
|
|
+ assert not remaining_bytes
|
|
|
+
|
|
|
+
|
|
|
def split_sequence_by_delimiter(
|
|
|
sequence: typing.Sequence, delimiter: typing.Any, delimiter_min_length: int = 1
|
|
|
) -> typing.Iterator[typing.Sequence]:
|