From 491739019cd62a37a510537680ee6b44f83c506e Mon Sep 17 00:00:00 2001 From: Aaron Lichtman Date: Wed, 21 Jun 2023 07:58:39 -0700 Subject: [PATCH] More refactoring --- jrnl/plugins/calendar_heatmap_exporter.py | 4 ++-- jrnl/plugins/dates_exporter.py | 4 ++-- jrnl/plugins/util.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jrnl/plugins/calendar_heatmap_exporter.py b/jrnl/plugins/calendar_heatmap_exporter.py index ab7bb4c2..3eecbeb2 100644 --- a/jrnl/plugins/calendar_heatmap_exporter.py +++ b/jrnl/plugins/calendar_heatmap_exporter.py @@ -13,7 +13,7 @@ from rich.table import Table from rich.text import Text from jrnl.plugins.text_exporter import TextExporter -from jrnl.plugins.util import get_journal_frequency_as_dict +from jrnl.plugins.util import get_journal_frequency_nested if TYPE_CHECKING: from jrnl.datatypes import NestedDict @@ -107,5 +107,5 @@ class CalendarHeatmapExporter(TextExporter): @classmethod def export_journal(cls, journal: "Journal"): """Returns dates and their frequencies for an entire journal.""" - journal_entry_date_frequency = get_journal_frequency_as_dict(journal) + journal_entry_date_frequency = get_journal_frequency_nested(journal) return cls.print_calendar_heatmap(journal_entry_date_frequency) diff --git a/jrnl/plugins/dates_exporter.py b/jrnl/plugins/dates_exporter.py index 6a20170b..f35f2c95 100644 --- a/jrnl/plugins/dates_exporter.py +++ b/jrnl/plugins/dates_exporter.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING from jrnl.plugins.text_exporter import TextExporter -from jrnl.plugins.util import get_journal_frequency_as_str +from jrnl.plugins.util import get_journal_frequency_one_level if TYPE_CHECKING: from jrnl.journals import Entry @@ -24,6 +24,6 @@ class DatesExporter(TextExporter): @classmethod def export_journal(cls, journal: "Journal") -> str: """Returns dates and their frequencies for an entire journal.""" - date_counts = get_journal_frequency_as_str(journal) + date_counts = get_journal_frequency_one_level(journal) result = "\n".join(f"{date}, {count}" for date, count in date_counts.items()) return result diff --git a/jrnl/plugins/util.py b/jrnl/plugins/util.py index 55c7b119..523dd95a 100644 --- a/jrnl/plugins/util.py +++ b/jrnl/plugins/util.py @@ -33,7 +33,7 @@ def oxford_list(lst: list) -> str: return ", ".join(lst[:-1]) + ", or " + lst[-1] -def get_journal_frequency_as_dict(journal: "Journal") -> NestedDict: +def get_journal_frequency_nested(journal: "Journal") -> NestedDict: """Returns a NestedDict of the form {year: {month: {day: count}}}""" journal_frequency = NestedDict() for entry in journal.entries: @@ -46,7 +46,7 @@ def get_journal_frequency_as_dict(journal: "Journal") -> NestedDict: return journal_frequency -def get_journal_frequency_as_str(journal: "Journal") -> Counter: +def get_journal_frequency_one_level(journal: "Journal") -> Counter: """Returns a Counter of the form {date (YYYY-MM-DD): count}""" date_counts = Counter() for entry in journal.entries: