about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-08-12 16:16:30 -0500
committerFrederick Muriuki Muriithi2024-08-12 16:16:30 -0500
commitbe09ad3e0746d2e9df03a65941f869fbc4f4ca47 (patch)
tree6247c0503083885e64d4893b9a79f6f7aa7d3148
parent42d6423578fe61857d1afbfc3be37d052b4bb39f (diff)
downloadgn-uploader-be09ad3e0746d2e9df03a65941f869fbc4f4ca47.tar.gz
Bug: Ensure file type values are lists.
-rw-r--r--r_qtl/r_qtl2.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py
index fc6feb5..9da4081 100644
--- a/r_qtl/r_qtl2.py
+++ b/r_qtl/r_qtl2.py
@@ -181,13 +181,24 @@ def control_data(control_src: Union[Path, ZipFile]) -> dict:
     ------
     r_qtl.exceptions.InvalidFormat
     """
+    def __cleanup__(cdata):
+        return {
+            **cdata,
+            **dict((filetype,
+                    ([cdata[filetype]] if isinstance(cdata[filetype], str)
+                else cdata[filetype])
+                    ) for filetype in
+                   (typ for typ in cdata.keys() if typ in FILE_TYPES))
+        }
+
     if isinstance(control_src, ZipFile):
-        return __control_data_from_zipfile__(control_src)
+        return __cleanup__(__control_data_from_zipfile__(control_src))
     if isinstance(control_src, Path):
         if is_zipfile(control_src):
-            return __control_data_from_zipfile__(ZipFile(control_src))
+            return __cleanup__(
+                __control_data_from_zipfile__(ZipFile(control_src)))
         if control_src.is_dir():
-            return __control_data_from_dirpath__(control_src)
+            return __cleanup__(__control_data_from_dirpath__(control_src))
     raise InvalidFormat(
         "Expects either a zipfile.ZipFile object or a pathlib.Path object "
         "pointing to a directory containing the R/qtl2 bundle.")