Checking if the graphs index file exists before trying to read it
@@ -855,6 +855,7 @@ class POW(object):
def _graphs_index(self):
idx_fname = pth_join(self.powdir, 'graphs', 'index')
+ if exists(idx_fname):
with open(idx_fname) as index_file:
for l in index_file:
yield l.strip().split(' ')
@@ -872,13 +873,9 @@ class POW(object):
return self._fnc
def _read_graphs_index(self):
- idx_fname = pth_join(self.powdir, 'graphs', 'index')
ctx_index = dict()
fname_index = dict()
- if exists(idx_fname):
- with open(idx_fname) as index_file:
- for l in index_file:
- fname, ctx = l.strip().split(' ')
+ for fname, ctx in self._graphs_index():
ctx_index[ctx] = pth_join(self.powdir, 'graphs', fname)
fname_index[fname] = ctx
self._cfn = ctx_index
