mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-18 03:58:32 +02:00
Since we're implementing a plugin system that relies on implicit namespacing, we should remove these files so that they don't confuse and muddle our virtual envs (like the ones we use to run tests). Also, they're not longer needed as of Python 3.3. PEP 420 says: Allowing implicit namespace packages means that the requirement to provide an __init__.py file can be dropped completely...
32 lines
953 B
Python
32 lines
953 B
Python
# encoding: utf-8
|
|
# Copyright (C) 2012-2021 jrnl contributors
|
|
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
from collections import Counter
|
|
|
|
from jrnl.plugins.base import BaseExporter
|
|
|
|
from jrnl.__version__ import __version__
|
|
|
|
|
|
class Exporter(BaseExporter):
|
|
"""This Exporter lists dates and their respective counts, for heatingmapping etc."""
|
|
|
|
names = ["dates"]
|
|
extension = "dates"
|
|
version = __version__
|
|
|
|
@classmethod
|
|
def export_entry(cls, entry):
|
|
raise NotImplementedError
|
|
|
|
@classmethod
|
|
def export_journal(cls, journal):
|
|
"""Returns dates and their frequencies for an entire journal."""
|
|
date_counts = Counter()
|
|
for entry in journal.entries:
|
|
# entry.date.date() gets date without time
|
|
date = str(entry.date.date())
|
|
date_counts[date] += 1
|
|
result = "\n".join(f"{date}, {count}" for date, count in date_counts.items())
|
|
return result
|