From f136fd9657a5bdb23e573be090733e36a7e4fd91 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 11 Apr 2020 12:43:56 -0600 Subject: [PATCH 1/5] [YAML Exporter] fix starred spelling (#907) * fix starred spelling c.f. #835 --- features/exporting.feature | 2 +- jrnl/plugins/yaml_exporter.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/exporting.feature b/features/exporting.feature index 5705fda1..89abfd0e 100644 --- a/features/exporting.feature +++ b/features/exporting.feature @@ -129,7 +129,7 @@ Feature: Exporting a Journal """ title: I have an @idea: date: 2013-04-09 15:39 - stared: False + starred: False tags: idea, journal (1) write a command line @journal software diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 430b68f7..6a550b0c 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -104,10 +104,10 @@ class YAMLExporter(TextExporter): # source directory is entry.journal.config['journal'] # output directory is...? - return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}".format( + return "title: {title}\ndate: {date}\nstarred: {starred}\ntags: {tags}\n{dayone} {body} {space}".format( date=date_str, title=entry.title, - stared=entry.starred, + starred=entry.starred, tags=", ".join([tag[1:] for tag in entry.tags]), dayone=dayone_attributes, body=newbody, From d96a20d3e737ba518597f202bd96cba6ba62ce86 Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sat, 11 Apr 2020 18:51:43 +0000 Subject: [PATCH 2/5] Updating changelog [ci skip] --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63fa61a6..2ac4c88f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - Merge in temp branches for v2.4 [\#897](https://github.com/jrnl-org/jrnl/pull/897) ([wren](https://github.com/wren)) +**Fixed bugs:** + +- Fix typo in YAML exporter \("stared" -\> "starred"\) [\#907](https://github.com/jrnl-org/jrnl/pull/907) ([MinchinWeb](https://github.com/MinchinWeb)) + **Build:** - Update Poetry requirements for testing latest Python version [\#898](https://github.com/jrnl-org/jrnl/pull/898) ([wren](https://github.com/wren)) From ee9974a84e1e20d99b12cf96bd9e4983e7cc1a58 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 11 Apr 2020 13:08:04 -0600 Subject: [PATCH 3/5] [DayOne] support moderm `plistlib` (#909) The API of the standard library's `plistlib` changed with version 3.4 of Python, and the old API is being removed in Python 3.9. In other words, the new API is supported by all version of Python we current support (3.6 to 3.8). See https://docs.python.org/3.4/library/plistlib.html for more details. --- jrnl/DayOneJournal.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index 8e8b2cd0..af82333c 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -8,6 +8,7 @@ import re from datetime import datetime import time import fnmatch +from pathlib import Path import plistlib import pytz import uuid @@ -43,7 +44,7 @@ class DayOne(Journal.Journal): for filename in filenames: with open(filename, "rb") as plist_entry: try: - dict_entry = plistlib.readPlist(plist_entry) + dict_entry = plistlib.load(plist_entry, fmt=plistlib.FMT_XML) except self.PLIST_EXCEPTIONS: pass else: @@ -84,8 +85,10 @@ class DayOne(Journal.Journal): if not hasattr(entry, "uuid"): entry.uuid = uuid.uuid1().hex - filename = os.path.join( - self.config["journal"], "entries", entry.uuid.upper() + ".doentry" + fn = ( + Path(self.config["journal"]) + / "entries" + / (entry.uuid.upper() + ".doentry") ) entry_plist = { @@ -99,7 +102,9 @@ class DayOne(Journal.Journal): for tag in entry.tags ], } - plistlib.writePlist(entry_plist, filename) + # plistlib expects a binary object + with fn.open(mode="wb") as f: + plistlib.dump(entry_plist, f, fmt=plistlib.FMT_XML, sort_keys=False) for entry in self._deleted_entries: filename = os.path.join( self.config["journal"], "entries", entry.uuid + ".doentry" From 9627ed1bd133292957600d24595d3be69b5f2f9f Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sat, 11 Apr 2020 19:15:21 +0000 Subject: [PATCH 4/5] Updating changelog [ci skip] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac4c88f..a54d1e3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ **Fixed bugs:** +- Fix Python 3.9 incompatibility by updating plistlib [\#909](https://github.com/jrnl-org/jrnl/pull/909) ([MinchinWeb](https://github.com/MinchinWeb)) - Fix typo in YAML exporter \("stared" -\> "starred"\) [\#907](https://github.com/jrnl-org/jrnl/pull/907) ([MinchinWeb](https://github.com/MinchinWeb)) **Build:** From 779c8fbc2f1161a8ef3b3ea33d33395fa7d5250d Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 11 Apr 2020 13:28:22 -0600 Subject: [PATCH 5/5] Test Version match (#887) * [Tests] makes sure `--version` works Directly reads the version number from pyproject.toml * Tag the tests To run just this test, use `behave --tags=deployments_tests` --- features/regression.feature | 7 +++++++ features/steps/core.py | 11 +++++++++++ poetry.lock | 2 +- pyproject.toml | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/features/regression.feature b/features/regression.feature index 5aa1db06..4dc35b5a 100644 --- a/features/regression.feature +++ b/features/regression.feature @@ -122,3 +122,10 @@ Feature: Zapped bugs should stay dead. Then the output should contain "This thing happened yesterday" Then the output should contain "Adding an entry right now." Then the output should not contain "A future entry." + + @deployment_tests + Scenario: Version numbers should stay in sync + Given we use the config "basic.yaml" + When we run "jrnl --version" + Then we should get no error + Then the output should contain pyproject.toml version diff --git a/features/steps/core.py b/features/steps/core.py index 36b6573a..6eebd575 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -19,6 +19,8 @@ import keyring import tzlocal import shlex import sys +from pathlib import Path +import toml consts = pdt.Constants(usePyICU=False) consts.DOWParseStyle = -1 # Prefers past weekdays @@ -207,6 +209,15 @@ def check_output_time_inline(context, text): assert output_date in out, output_date +@then("the output should contain pyproject.toml version") +def check_output_version_inline(context): + out = context.stdout_capture.getvalue() + pyproject = (Path(__file__) / ".." / ".." / ".." / "pyproject.toml").resolve() + pyproject_contents = toml.load(pyproject) + pyproject_version = pyproject_contents["tool"]["poetry"]["version"] + assert pyproject_version in out, pyproject_version + + @then("the output should contain") @then('the output should contain "{text}"') @then('the output should contain "{text}" or "{text2}"') diff --git a/poetry.lock b/poetry.lock index 65356424..88eb5b3f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -522,7 +522,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "17cf8d4cf5a772217160daf312f590901dea4a3f5545d003035f3fb713a70f07" +content-hash = "afeb906a1ba51bc9fc4e8c19c0b2c63bb5c9529697c9496d6edb64b509da9e0f" python-versions = ">=3.6.0, <3.9.0" [metadata.files] diff --git a/pyproject.toml b/pyproject.toml index 20f2c306..2a52a7e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ behave = "^1.2" mkdocs = "^1.0" flake8 = "^3.7" black = {version = "^19.10b0",allow-prereleases = true} +toml = "^0.10.0" [tool.poetry.scripts] jrnl = 'jrnl.cli:run'