From dcafd88b86db0c59d7ad0a8391ba20596f34ffc2 Mon Sep 17 00:00:00 2001 From: olari Date: Mon, 12 Jul 2021 14:03:45 +0300 Subject: [PATCH] :*) --- journal.py | 4 ++-- migrations/2021-07-06_fix.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 migrations/2021-07-06_fix.py diff --git a/journal.py b/journal.py index dce5677..757c4f4 100644 --- a/journal.py +++ b/journal.py @@ -727,7 +727,7 @@ def parse_day(text): return { 'title': title, 'header': parse_header(header), - 'entries': [parse_entry(timestamp, content) for timestamp, content in entries], + 'entries': [parse_entry(timestamp, content) for timestamp, content in entries] } def generate_day(day): @@ -762,7 +762,7 @@ def import_journal(fpath): }, 'files': { fname: (fpath / fname).read_text() - for fname in ['habits', 'godword', 'tasks', 'foods'] + for fname in ['habits', 'godword', 'tasks', 'foods', 'backup'] } } diff --git a/migrations/2021-07-06_fix.py b/migrations/2021-07-06_fix.py new file mode 100644 index 0000000..1e85156 --- /dev/null +++ b/migrations/2021-07-06_fix.py @@ -0,0 +1,16 @@ +from copy import deepcopy +from pathlib import Path +from shutil import copy +import json + +journal_path = Path.home() / '.journal.json' + +copy(str(journal_path), str(journal_path.with_suffix('.bkp'))) + +journal = json.loads(journal_path.read_text()) +new_journal = deepcopy(journal) + +for day in journal['days']: + new_journal['days'][day]['entries'] = journal['days'][day]['entries'][0] + +journal_path.write_text(json.dumps(new_journal))