aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--r_qtl/r_qtl2.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py
index 0a96e7c..a34caac 100644
--- a/r_qtl/r_qtl2.py
+++ b/r_qtl/r_qtl2.py
@@ -30,6 +30,26 @@ def __special_file__(filename):
return (is_macosx_special_file or is_nix_hidden_file)
+def extract(zfile: ZipFile, outputdir: Path) -> tuple[Path, ...]:
+ """Extract a ZipFile
+
+ This function will extract a zipfile `zfile` to the directory `outputdir`.
+
+ Parameters
+ ----------
+ zfile: zipfile.ZipFile object - the zipfile to extract.
+ outputdir: Optional pathlib.Path object - where the extracted files go.
+
+ Returns
+ -------
+ A tuple of Path objects, each pointing to a member in the zipfile.
+ """
+ outputdir.mkdir(parents=True, exist_ok=True)
+ return tuple(Path(zfile.extract(member, outputdir))
+ for member in zfile.namelist()
+ if not __special_file__(member))
+
+
def control_data(zfile: ZipFile) -> dict:
"""Retrieve the control file from the zip file info."""
files = tuple(filename