Fix download model binary script to get correct lines on parsing table
authorGustavo Serra Scalet <gsscalet@gmail.com>
Thu, 6 Aug 2015 17:37:20 +0000 (14:37 -0300)
committerGustavo Serra Scalet <gsscalet@gmail.com>
Thu, 6 Aug 2015 17:37:20 +0000 (14:37 -0300)
The base reference of "bottom" variable was relative to the "top+1" and
not to the whole readlines output. It ended up without all the lines.

That could work for some gists however for the model I was looking for (see
below) the sha1 key was not being parsed, as it was missing the last line.

tested with the following gist:
longjon/1bf3aa1e0b8e788d7e1d

scripts/download_model_binary.py

index 48e9015..03a50f6 100755 (executable)
@@ -32,7 +32,7 @@ def parse_readme_frontmatter(dirname):
     with open(readme_filename) as f:
         lines = [line.strip() for line in f.readlines()]
     top = lines.index('---')
-    bottom = lines[top + 1:].index('---')
+    bottom = lines.index('---', top + 1)
     frontmatter = yaml.load('\n'.join(lines[top + 1:bottom]))
     assert all(key in frontmatter for key in required_keys)
     return dirname, frontmatter