Repository: fatiando/pooch

Issue:
Check for empty lines in registry files
**Description of the desired feature**

Pooch reads in the files and their hashes from *registry files* using `Pooch.load_registry`. Right now, it fails if there is a blank line anywhere in the file (see https://github.com/fatiando/pooch/blob/master/pooch/core.py#L444).

Ideally, the code should skip any lines for which `line.strip()` is empty. While we're at it, the line number reported in the error message is off by one because `enumerate` starts from 0 so we should add one to it.

Discussion:

Patch:
diff --git a/pooch/core.py b/pooch/core.py
index e205b67..6fcfd3b 100644
--- a/pooch/core.py
+++ b/pooch/core.py
@@ -490,20 +490,21 @@ class Pooch:
                     line = line.decode("utf-8")
 
                 elements = line.strip().split()
-                if len(elements) > 3 or len(elements) < 2:
+                if not len(elements) in [0, 2, 3]:
                     raise OSError(
                         "Invalid entry in Pooch registry file '{}': "
                         "expected 2 or 3 elements in line {} but got {}. "
                         "Offending entry: '{}'".format(
-                            fname, linenum, len(elements), line
+                            fname, linenum + 1, len(elements), line
                         )
                     )
-                file_name = elements[0]
-                file_sha256 = elements[1]
-                if len(elements) == 3:
-                    file_url = elements[2]
-                    self.urls[file_name] = file_url
-                self.registry[file_name] = file_sha256
+                if elements:
+                    file_name = elements[0]
+                    file_sha256 = elements[1]
+                    if len(elements) == 3:
+                        file_url = elements[2]
+                        self.urls[file_name] = file_url
+                    self.registry[file_name] = file_sha256
 
     def is_available(self, fname):
         """
diff --git a/requirements-dev.txt b/requirements-dev.txt
index a741383..2b303be 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -2,5 +2,5 @@
 pytest
 pytest-cov
 coverage
-sphinx=2.2.1
-sphinx_rtd_theme=0.4.3
+sphinx==2.2.1
+sphinx_rtd_theme==0.4.3


Test patch:
diff --git a/pooch/tests/data/registry.txt b/pooch/tests/data/registry.txt
index 8e07eb2..deeae4e 100644
--- a/pooch/tests/data/registry.txt
+++ b/pooch/tests/data/registry.txt
@@ -2,8 +2,10 @@ subdir/tiny-data.txt baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415
 tiny-data.txt baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d
 large-data.txt 98de171fb320da82982e6bf0f3994189fff4b42b23328769afce12bdd340444a
 tiny-data.zip 0d49e94f07bc1866ec57e7fd1b93a351fba36842ec9b13dd50bf94e8dfa35cbb
+
 store.zip 0498d2a001e71051bbd2acd2346f38da7cbd345a633cb7bf0f8a20938714b51a
 tiny-data.tar.gz 41503f083814f43a01a8e9a30c28d7a9fe96839a99727a7fdd0acf7cd5bab63b
+
 store.tar.gz 088c7f4e0f1859b1c769bb6065de24376f366374817ede8691a6ac2e49f29511
 tiny-data.txt.bz2 753663687a4040c90c8578061867d1df623e6aa8011c870a5dbd88ee3c82e306
 tiny-data.txt.gz 2e2da6161291657617c32192dba95635706af80c6e7335750812907b58fd4b52