spines.utils.file¶
File utilities for spines.
-
spines.utils.file.
extract_archive
(path: str, output: str, fmt: [<class 'str'>, None] = None) → None[source]¶ Extracts the specified archive contents from file
- Parameters
path (str) – Archive file path to extract files from.
output (str) – Output directory to save contents to.
fmt (str, optional) – File format to load archive as (default is
None
, which will attempt to infer the format from the path).
-
spines.utils.file.
get_archive_extension
(fmt: str) → str[source]¶ Gets the file extension based on format given
- Parameters
fmt (str) – Format to get file extension for.
- Returns
File extension to use for the given format.
- Return type
str
-
spines.utils.file.
load_pickle
(*path) → object[source]¶ Load a single pickled object from file
- Parameters
file (str) – File to load.
- Returns
Object loaded from file.
- Return type
object
-
spines.utils.file.
save_archive
(path: str, files: List[str], fmt: [<class 'str'>, None] = None) → str[source]¶ Saves a set of files into a single archive file
- Parameters
path (str) – Path to save the archive file to.
files (
list
ofstr
) – Files to bundle into the archive.fmt (str, optional) – Archive file format to use.
- Returns
Path to the output archive file created.
- Return type
str