Repository: fatiando/pooch

Issue:
Registry files cannot handle file names containing spaces
**Description of the problem:**

The way that `registry.txt` files are parsed [here](https://github.com/fatiando/pooch/blob/main/pooch/core.py#L659) does not allow filenames to contain spaces. This could be fixed by implementing advanced parsing that allows escaping using enclosing quotes or backslashes.

**Full code that generated the error**

With [registry.txt](https://github.com/fatiando/pooch/files/9130660/registry.txt) in path:

```python
import pooch
P = pooch.create(
    path=pooch.os_cache("test"),
    base_url="ignored"
)
P.load_registry("registry.txt")
```


**Full error message**

```
OSError: Invalid entry in Pooch registry file './registry.txt': expected 2 or 3 elements in line 1 but got 7. Offending entry: '"How To - Minimal Workflow.pdf" sha256:7d4da5fe4d0438437834fe846608b93959dcb80ded941eb85663b2d905c54000 https://heidata.uni-heidelberg.de/api/access/datafile/:persistentId?persistentId=doi:10.11588/data/TJNQZG/DWSXML'
```



Discussion:
welcome[bot]: 💖 **Thank you for opening your first pull request in this repository!** 💖

A few things to keep in mind:

* [Authorship Guidelines](https://github.com/fatiando/community/blob/main/AUTHORSHIP.md): Our rules for giving you credit for your contributions, including authorship on publications and [Zenodo](https://zenodo.org/communities/fatiando) archives.
* [Code of Conduct](https://github.com/fatiando/community/blob/main/CODE_OF_CONDUCT.md): How we expect people to interact in our projects.

⭐ **No matter what, we are really grateful that you put in the effort to do this!** ⭐

dokempf: I think this is ready for review. I had a look at the CodeCov failure and it seems quite unrelated, the changes on this PR should be all covered.
leouieda: Thanks @dokempf! Looks great to me. Just waiting on CI to finish 🤖. 

Patch:
diff --git a/AUTHORS.md b/AUTHORS.md
index 2374903..5266106 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -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))
diff --git a/pooch/core.py b/pooch/core.py
index 7b2b3b8..24267f9 100644
--- a/pooch/core.py
+++ b/pooch/core.py
@@ -11,6 +11,7 @@ import os
 import time
 import contextlib
 from pathlib import Path
+import shlex
 import shutil
 import ftplib
 
@@ -656,7 +657,7 @@ class Pooch:
                 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}': "


Test patch:
diff --git a/pooch/tests/data/registry-spaces.txt b/pooch/tests/data/registry-spaces.txt
new file mode 100644
index 0000000..0bd27f2
--- /dev/null
+++ b/pooch/tests/data/registry-spaces.txt
@@ -0,0 +1,2 @@
+"file with spaces.txt" baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d
+other\ with\ spaces.txt baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d
diff --git a/pooch/tests/test_core.py b/pooch/tests/test_core.py
index 4736603..268bda2 100644
--- a/pooch/tests/test_core.py
+++ b/pooch/tests/test_core.py
@@ -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"