diff --git a/pridepy/pdc/client.py b/pridepy/pdc/client.py index 3e217ed..275267f 100644 --- a/pridepy/pdc/client.py +++ b/pridepy/pdc/client.py @@ -139,7 +139,7 @@ def parse_accessions(accession: str) -> List[str]: raise ValueError("--accession must not be empty") source_path = Path(accession).expanduser() - if source_path.exists(): + if source_path.is_file(): if source_path.suffix.lower() != ".csv": raise ValueError(f"Only CSV accession files are supported: {source_path}") return _read_accessions_from_csv(source_path) @@ -168,7 +168,7 @@ def parse_download_requests(accession: str, file_type: Optional[str] = None) -> command_file_type = normalize_file_type(file_type) if file_type else None source_path = Path(accession).expanduser() - if source_path.exists(): + if source_path.is_file(): if source_path.suffix.lower() != ".csv": raise ValueError(f"Only CSV accession files are supported: {source_path}") diff --git a/pridepy/tests/test_pdc_client.py b/pridepy/tests/test_pdc_client.py index 472cc0b..5edfe68 100644 --- a/pridepy/tests/test_pdc_client.py +++ b/pridepy/tests/test_pdc_client.py @@ -60,6 +60,17 @@ class TestPDCAccessions(TestCase): def test_single_accession(self): assert parse_accessions("PDC000109") == ["PDC000109"] + def test_accession_not_confused_with_same_named_directory(self): + with tempfile.TemporaryDirectory() as tmp_dir: + old_cwd = os.getcwd() + os.chdir(tmp_dir) + try: + os.makedirs("PDC000714") + assert parse_accessions("PDC000714") == ["PDC000714"] + assert parse_download_requests("PDC000714") == [PDCDownloadRequest("PDC000714", None)] + finally: + os.chdir(old_cwd) + def test_comma_accessions_are_deduped(self): assert parse_accessions("PDC000109,PDC000110,PDC000109") == [ "PDC000109", diff --git a/pyproject.toml b/pyproject.toml index b94d076..e557eec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pridepy" -version = "0.0.16" +version = "0.0.17" description = "Python Client library for PRIDE Rest API" readme = "README.md" requires-python = ">=3.9"