[GH-632] confirming that each journal can be parsed during upgrade, and aborting upgrade if not

[GH-632] raising exception in upgrade.py on fail
Handling it in install.py to prevent config from being overwritten when upgrade fails
[GH-632] removing unnecessary whitespace
[GH-632] removing unreachable return statement
[GH-632] adding call to action to report issue when upgrade fails
This commit is contained in:
Micah Jerome Ellison 2019-08-24 13:50:10 -07:00
parent 328faa401c
commit 8abbdf4db5
6 changed files with 68 additions and 30 deletions

View file

@ -84,9 +84,20 @@ class Journal(object):
def write(self, filename=None):
"""Dumps the journal into the config file, overwriting it"""
filename = filename or self.config['journal']
text = "\n".join([e.__unicode__() for e in self.entries])
text = self._to_text()
self._store(filename, text)
def validate_parsing(self):
"""Confirms that the jrnl is still parsed correctly after being dumped to text."""
new_entries = self._parse(self._to_text())
for i, entry in enumerate(self.entries):
if entry != new_entries[i]:
return False
return True
def _to_text(self):
return "\n".join([e.__unicode__() for e in self.entries])
def _load(self, filename):
raise NotImplementedError