From be09ad3e0746d2e9df03a65941f869fbc4f4ca47 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 12 Aug 2024 16:16:30 -0500 Subject: Bug: Ensure file type values are lists. --- r_qtl/r_qtl2.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'r_qtl/r_qtl2.py') 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.") -- cgit v1.2.3