Repository: fatiando/pooch

Issue:
Comments in registry file?
It could be worthwhile to support comments in registry files. For simplicity comments one could require that they need to be on a new line:

```
# this ressource
c137.csv 19uheidhlkjdwhoiwuhc0uhcwljchw9ochwochw89dcgw9dcgwc
# that ressource
cronen.csv 1upodh2ioduhw9celdjhlfvhksgdwikdgcowjhcwoduchowjg8w
```
However, it's probably not really possible to use this in a backward-compatible way...

**Are you willing to help implement and maintain this feature?** Yes

<!--
Every feature we add is code that we will have to maintain and keep updated.
This takes a lot of effort. If you are willing to be involved in the project
and help maintain your feature, it will make it easier for us to accept it.
-->


Discussion:
welcome[bot]: 💖 Thanks for opening your first pull request! 💖

Please make sure you read the following:

* [Authorship Guidelines](https://github.com/fatiando/contributing/blob/master/CONTRIBUTING.md): Our rules for giving you credit for your contributions, including authorship on publications and [Zenodo](https://zenodo.org/communities/fatiando) archives.
* [Contributing Guide](https://github.com/fatiando/contributing/blob/master/CONTRIBUTING.md): What the review process is like and our infrastructure for testing and documentation.
* [Code of Conduct](https://github.com/fatiando/contributing/blob/master/CODE_OF_CONDUCT.md): How we expect people to interact in our projects.

A few things to keep in mind:

* Remember to run `make format` to make sure your code follows our style guide.
* If you need help writing tests, take a look at the existing ones for inspiration. If you don't know where to start, let us know and we'll walk you through it.
* All new features should be documented. It helps to write the docstrings for your functions/classes before writing the code. This will help you think about your code design and results in better code.
* No matter what, we are really grateful that you put in the effort to do this! ⭐


Patch:
diff --git a/AUTHORS.md b/AUTHORS.md
index 9f353a8..e644199 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -4,6 +4,7 @@ The following people have made contributions to the project (in alphabetical
 order by last name) and are considered "The Pooch Developers":
 
 * [Anderson Banihirwe](https://github.com/andersy005) - The US National Center for Atmospheric Research, USA (ORCID: [0000-0001-6583-571X](https://orcid.org/0000-0001-6583-571X))
+* [Mathias Hauser](https://github.com/mathause) - Institute for Atmospheric and Climate Science, ETH Zurich, Zurich, Switzerland (ORCID: [0000-0002-0057-4878](https://orcid.org/0000-0002-0057-4878))
 * [Hugo van Kemenade](https://github.com/hugovk) - Independent (Non-affiliated) (ORCID: [0000-0001-5715-8632](https://www.orcid.org/0000-0001-5715-8632))
 * [Kacper Kowalik](https://github.com/Xarthisius) - National Center for Supercomputing Applications, Univeristy 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)
diff --git a/doc/usage.rst b/doc/usage.rst
index da638ea..2ad43df 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -616,6 +616,22 @@ prefixed with ``alg:``, e.g.
     c137.csv sha1:e32b18dab23935bc091c353b308f724f18edcb5e
     cronen.csv md5:b53c08d3570b82665784cedde591a8b0
 
+From version 1.2 the registry file can also contain line comments, prepended with a ``#``, e.g.:
+
+.. code-block:: none
+
+    # C-137 sample data
+    c137.csv 19uheidhlkjdwhoiwuhc0uhcwljchw9ochwochw89dcgw9dcgwc
+    # Cronenberg sample data
+    cronen.csv 1upodh2ioduhw9celdjhlfvhksgdwikdgcowjhcwoduchowjg8w
+
+.. note::
+
+    Make sure you set the pooch version in your ``setup.py`` to version 1.2 or
+    later when using comments as earlier versions cannot handle them:
+     ``install_requires = [..., "pooch>=1.2", ...]``
+
+
 To make sure the registry file is shipped with your package, include the following in
 your ``MANIFEST.in`` file:
 
diff --git a/pooch/core.py b/pooch/core.py
index 9b3ea19..45b6704 100644
--- a/pooch/core.py
+++ b/pooch/core.py
@@ -615,7 +615,8 @@ class Pooch:
         a space. Hash can specify checksum algorithm using "alg:hash" format.
         In case no algorithm is provided, SHA256 is used by default.
         Only one file per line is allowed. Custom download URLs for individual
-        files can be specified as a third element on the line.
+        files can be specified as a third element on the line. Line comments
+        can be added and must be prepended with ``#``.
 
         Parameters
         ----------
@@ -635,7 +636,12 @@ class Pooch:
                 if isinstance(line, bytes):
                     line = line.decode("utf-8")
 
-                elements = line.strip().split()
+                line = line.strip()
+                # skip line comments
+                if line.startswith("#"):
+                    continue
+
+                elements = line.split()
                 if not len(elements) in [0, 2, 3]:
                     raise OSError(
                         "Invalid entry in Pooch registry file '{}': "


Test patch:
diff --git a/pooch/tests/data/registry_comments.txt b/pooch/tests/data/registry_comments.txt
new file mode 100644
index 0000000..89fd8a6
--- /dev/null
+++ b/pooch/tests/data/registry_comments.txt
@@ -0,0 +1,14 @@
+# a comment
+subdir/tiny-data.txt baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d
+tiny-data.txt baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d
+large-data.txt 98de171fb320da82982e6bf0f3994189fff4b42b23328769afce12bdd340444a
+tiny-data.zip 0d49e94f07bc1866ec57e7fd1b93a351fba36842ec9b13dd50bf94e8dfa35cbb
+
+ # a comment with a starting space
+store.zip 0498d2a001e71051bbd2acd2346f38da7cbd345a633cb7bf0f8a20938714b51a
+tiny-data.tar.gz 41503f083814f43a01a8e9a30c28d7a9fe96839a99727a7fdd0acf7cd5bab63b
+
+store.tar.gz 088c7f4e0f1859b1c769bb6065de24376f366374817ede8691a6ac2e49f29511
+tiny-data.txt.bz2 753663687a4040c90c8578061867d1df623e6aa8011c870a5dbd88ee3c82e306
+tiny-data.txt.gz 2e2da6161291657617c32192dba95635706af80c6e7335750812907b58fd4b52
+tiny-data.txt.xz 99dcb5c32a6e916344bacb4badcbc2f2b6ee196977d1d8187610c21e7e607765
diff --git a/pooch/tests/test_core.py b/pooch/tests/test_core.py
index 5c0ecbd..0a8478b 100644
--- a/pooch/tests/test_core.py
+++ b/pooch/tests/test_core.py
@@ -231,6 +231,14 @@ def test_pooch_load_registry():
     assert pup.registry_files.sort() == list(REGISTRY).sort()
 
 
+def test_pooch_load_registry_comments():
+    "Loading the registry from a file and strip line comments"
+    pup = Pooch(path="", base_url="")
+    pup.load_registry(os.path.join(DATA_DIR, "registry_comments.txt"))
+    assert pup.registry == REGISTRY
+    assert pup.registry_files.sort() == list(REGISTRY).sort()
+
+
 def test_pooch_load_registry_fileobj():
     "Loading the registry from a file object"
     path = os.path.join(DATA_DIR, "registry.txt")