import dascore as dc
import tempfile
from pathlib import Path
patch = dc.get_example_patch()
path = Path(tempfile.mkdtemp()) / "patch.pkl"
_ = dc.write(patch, path, "pickle")
# Only for a file you trust; unpickling it can run any code.
with dc.config_context(allow_pickle_format=True):
spool = dc.read(path)PickleIO
PickleIO()
Provides IO support for the pickle format.
Warning
Unpickling a file can run arbitrary code, so reading the PICKLE format is disabled by default. Enable it with the allow_pickle_format config setting, and only for files you trust: while it is on, any directory scan unpickles every file whose header names a DASCore Patch or Spool, whatever its extension. Detection reads only the header and never unpickles; reading or scanning a pickle without the setting raises PickleFormatDisabledError. Writing pickles needs no opt-in. Pickles also tie a file to the DASCore version which wrote it, so prefer DASDAE for storage.
Examples
Methods
| Name | Description |
|---|---|
| get_format | Derive the format name and version from the family detector. |
| get_metadata | Decode a pickle to describe its patches without retaining their arrays. |
| get_version | Return the version if the header names a DASCore Patch or Spool. |
| read | Read patches by selecting metadata and loading the resulting array windows. |
| read_array | Slice one logical patch from the entries decoded for this operation. |
| scan | Return patch metadata; the dispatcher attaches source provenance. |
| unit_members | Return the files identifying a directory unit of this format, if any. |
| write | Write a Patch/Spool to disk. |