remove template exporter

This commit is contained in:
MinchinWeb 2021-03-08 17:31:24 -07:00
parent e25869e9bc
commit 3795159767
3 changed files with 0 additions and 68 deletions

View file

@ -9,8 +9,6 @@ import jrnl.contrib.importer
import jrnl.plugins.exporter import jrnl.plugins.exporter
import jrnl.plugins.importer import jrnl.plugins.importer
from .template_exporter import __all__ as template_exporters
__exporters_builtin = list( __exporters_builtin = list(
pkgutil.iter_modules( pkgutil.iter_modules(
jrnl.plugins.exporter.__path__, jrnl.plugins.exporter.__name__ + "." jrnl.plugins.exporter.__path__, jrnl.plugins.exporter.__name__ + "."
@ -43,9 +41,6 @@ __exporter_types_contrib = {
for plugin in __exporters_contrib for plugin in __exporters_contrib
for name in importlib.import_module(plugin.name).Exporter.names for name in importlib.import_module(plugin.name).Exporter.names
} }
__exporter_types_template = {
name: plugin for plugin in template_exporters for name in plugin.names
}
__importer_types_builtin = { __importer_types_builtin = {
@ -62,7 +57,6 @@ __importer_types_contrib = {
__exporter_types = { __exporter_types = {
**__exporter_types_builtin, **__exporter_types_builtin,
**__exporter_types_contrib, **__exporter_types_contrib,
**__exporter_types_template,
} }
__importer_types = {**__importer_types_builtin, **__importer_types_contrib} __importer_types = {**__importer_types_builtin, **__importer_types_contrib}

View file

@ -1,44 +0,0 @@
#!/usr/bin/env python
# encoding: utf-8
# Copyright (C) 2012-2021 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
from glob import glob
import os
from jrnl.plugins.template import Template
from jrnl.plugins.exporter.text_exporter import Exporter as TextExporter
class GenericTemplateExporter(TextExporter):
"""This Exporter can convert entries and journals into text files."""
@classmethod
def export_entry(cls, entry):
"""Returns a string representation of a single entry."""
vars = {"entry": entry, "tags": entry.tags}
return cls.template.render_block("entry", **vars)
@classmethod
def export_journal(cls, journal):
"""Returns a string representation of an entire journal."""
vars = {"journal": journal, "entries": journal.entries, "tags": journal.tags}
return cls.template.render_block("journal", **vars)
def __exporter_from_file(template_file):
"""Create a template class from a file"""
name = os.path.basename(template_file).replace(".template", "")
template = Template.from_file(template_file)
return type(
str(f"{name.title()}TemplateExporter"),
(GenericTemplateExporter,),
{"names": [name], "extension": template.extension, "template": template},
)
__all__ = []
# Factory pattern to create Exporter classes for all available templates
for template_file in glob("jrnl/templates/*.template"):
__all__.append(__exporter_from_file(template_file))

View file

@ -1,18 +0,0 @@
---
extension: txt
---
{% block journal %}
{% for entry in entries %}
{% include entry %}
{% endfor %}
{% endblock %}
{% block entry %}
{{ entry.title }}
{{ "-" * len(entry.title) }}
{{ entry.body }}
{% endblock %}