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.
-->


Comments:

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")