more code clean up

tests pass locally...now for GitHub...
This commit is contained in:
MinchinWeb 2021-05-09 16:29:51 -06:00
parent 1fd04ad03d
commit 432681f8a3
5 changed files with 23 additions and 16 deletions

View file

@ -13,7 +13,10 @@ used alone (e.g. `jrnl --format json`) to display all entries from the selected
This page shows examples of all the built-in formats, but since `jrnl` supports adding
more formats through plugins, you may have more available on your system. Please see
`jrnl --help` for a list of which formats are available on your system.
`jrnl --version` for a list of which formats are available on your system. Note
that plugins can also override built-in formats, so review your installed
plugins if your output does not match what is listed here. You can also [write
your own plugins](./plugins.md) to create custom formats.
Any of these formats can be used interchangeably, and are only grouped into "display",
"data", and "report" formats below for convenience.

View file

@ -112,6 +112,7 @@ Feature: Custom formats
| basic_folder |
| basic_dayone |
@skip # template exporters have been removed
Scenario Outline: Exporting using custom templates
Given we use the config "<config>.yaml"
And we load template "sample.template"

View file

@ -3,10 +3,11 @@
# Copyright (C) 2012-2021 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
from jrnl.exception import JrnlError
from textwrap import TextWrapper
from jrnl.plugins.base import BaseExporter
from jrnl.plugins.util import check_provided_linewrap_viability
from ... import __version__
@ -83,14 +84,3 @@ class Exporter(BaseExporter):
def export_journal(cls, journal):
"""Returns a unicode representation of an entire journal."""
return "\n".join(cls.export_entry(entry) for entry in journal)
def check_provided_linewrap_viability(linewrap, card, journal):
if len(card[0]) > linewrap:
width_violation = len(card[0]) - linewrap
raise JrnlError(
"LineWrapTooSmallForDateFormat",
config_linewrap=linewrap,
columns=width_violation,
journal=journal,
)

View file

@ -3,6 +3,8 @@
# Copyright (C) 2012-2021 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
from jrnl.exception import JrnlError
def get_tags_count(journal):
"""Returns a set of tuples (count, tag) for all tags present in the journal."""
@ -25,3 +27,14 @@ def oxford_list(lst):
return lst[0] + " or " + lst[1]
else:
return ", ".join(lst[:-1]) + ", or " + lst[-1]
def check_provided_linewrap_viability(linewrap, card, journal):
if len(card[0]) > linewrap:
width_violation = len(card[0]) - linewrap
raise JrnlError(
"LineWrapTooSmallForDateFormat",
config_linewrap=linewrap,
columns=width_violation,
journal=journal,
)

View file

@ -1,8 +1,8 @@
from jrnl.exception import JrnlError
from jrnl.plugins.fancy_exporter import check_provided_linewrap_viability
import pytest
from jrnl.exception import JrnlError
from jrnl.plugins.util import check_provided_linewrap_viability
@pytest.fixture()
def datestr():