From 5a06b49967d81dd703bebbb6ba39bb7ccdfe814d Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Sat, 2 Apr 2016 10:49:15 -0700 Subject: [PATCH] load the MD5 file, if present if the MD5 file is not present, then an earlier version of the tldp package generated the output directory, and we should re-run if the MD5 file is present in the output directory, load it into the dict() data structure and return it, so that a stale-check can be completed --- tldp/outputs.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tldp/outputs.py b/tldp/outputs.py index a023459..134c67c 100644 --- a/tldp/outputs.py +++ b/tldp/outputs.py @@ -7,6 +7,7 @@ from __future__ import unicode_literals import os import sys import errno +import codecs import logging from tldp.ldpcollection import LDPDocumentCollection @@ -91,10 +92,16 @@ class OutputNamingConvention(object): @property def md5sums(self): d = dict() - with codecs.open(self.MD5SUMS, encoding='utf-8') as f: - for line in f: - hashval, fname = line.strip().split() - d[fname] = hashval + try: + with codecs.open(self.MD5SUMS, encoding='utf-8') as f: + for line in f: + if line.startswith('#'): + continue + hashval, fname = line.strip().split() + d[fname] = hashval + except IOError as e: + if e.errno != errno.ENOENT: + raise return d