def close(self):
"""Close snippet file"""
- self.file.close()
+ if self.file:
+ self.file.close()
def remove(self):
self.revision = None
idx += 1
except IOError, e:
- log.error("Cannot open snippet file for book id = %d [rev=%d], %s" % (book_id, revision, e))
+ log.error("Cannot open snippet file for book id = %d [rev=%s], %s" % (book_id, revision, e))
return []
finally:
- if snippets:
- snippets.close()
+ snippets.close()
# remove verse end markers..
snips = map(lambda s: s and s.replace("/\n", "\n"), snips)