Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spaces in filenames in registry files #315

Merged
merged 4 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ order by last name) and are considered "The Pooch Developers":
* [Mark Harfouche](https://github.com/hmaarrfk) - Ramona Optics Inc. - [0000-0002-4657-4603](https://orcid.org/0000-0002-4657-4603)
* [Danilo Horta](https://github.com/horta) - EMBL-EBI, UK
* [Hugo van Kemenade](https://github.com/hugovk) - Independent (Non-affiliated) (ORCID: [0000-0001-5715-8632](https://www.orcid.org/0000-0001-5715-8632))
* [Dominic Kempf](https://github.com/dokempf) - Scientific Software Center, Heidelberg University, Germany (ORCID: [0000-0002-6140-2332](https://www.orcid.org/0000-0002-6140-2332))
* [Kacper Kowalik](https://github.com/Xarthisius) - National Center for Supercomputing Applications, University of Illinois at Urbana-Champaign, USA (ORCID: [0000-0003-1709-3744](https://www.orcid.org/0000-0003-1709-3744))
* [John Leeman](https://github.com/jrleeman)
* [Daniel McCloy](https://github.com/drammock) - University of Washington, USA (ORCID: [0000-0002-7572-3241](https://orcid.org/0000-0002-7572-3241))
Expand Down
3 changes: 2 additions & 1 deletion pooch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
import contextlib
from pathlib import Path
import shlex
import shutil
import ftplib

Expand Down Expand Up @@ -656,7 +657,7 @@ def load_registry(self, fname):
if line.startswith("#"):
continue

elements = line.split()
elements = shlex.split(line)
if not len(elements) in [0, 2, 3]:
raise OSError(
f"Invalid entry in Pooch registry file '{fname}': "
Expand Down
2 changes: 2 additions & 0 deletions pooch/tests/data/registry-spaces.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"file with spaces.txt" baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d
other\ with\ spaces.txt baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d
8 changes: 8 additions & 0 deletions pooch/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,14 @@ def test_pooch_load_registry_invalid_line():
pup.load_registry(os.path.join(DATA_DIR, "registry-invalid.txt"))


def test_pooch_load_registry_with_spaces():
"Should check that spaces in filenames are allowed in registry files"
pup = Pooch(path="", base_url="")
pup.load_registry(os.path.join(DATA_DIR, "registry-spaces.txt"))
assert "file with spaces.txt" in pup.registry
assert "other with spaces.txt" in pup.registry


@pytest.mark.network
def test_check_availability():
"Should correctly check availability of existing and non existing files"
Expand Down