Add trailing newlines to saved JSON files
authorW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 15:01:49 +0000 (10:01 -0500)
committerW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 15:01:49 +0000 (10:01 -0500)
quizzer/answerdb.py
quizzer/quiz.py

index 869641ec29a13221c715027efa73af13739da514..7ba4ba79b6db1c7f2d44726b682f7d63ed60056d 100644 (file)
@@ -34,6 +34,7 @@ class AnswerDatabase (dict):
         with self._open(mode='w', **kwargs) as f:
             _json.dump(
                 data, f, indent=2, separators=(',', ': '), sort_keys=True)
+            f.write('\n')
 
     def add(self, question, answer, correct):
         if question.prompt not in self:
index f0250c7ab83808d3bbd0af6b803abee619b62260..86b029ad526feb51a6770fcf01ed6a26aadfa364 100644 (file)
@@ -40,3 +40,4 @@ class Quiz (list):
         with self._open(mode='w', **kwargs) as f:
             _json.dump(
                 data, f, indent=2, separators=(',', ': '), sort_keys=True)
+            f.write('\n')