Merge branch 'develop' into flake-simplify

Conflicts:
  poetry.lock
  pyproject.toml
This commit is contained in:
Jonathan Wren 2022-11-01 21:03:39 -07:00
commit fe1f447bd0
No known key found for this signature in database
9 changed files with 119 additions and 44 deletions

View file

@ -152,6 +152,14 @@ jobs:
git commit -m "Update changelog [ci skip]"
git push origin "$BRANCH"
- name: Update tag to include changelog
if: startsWith(env.GITHUB_REF, 'refs/tags/')
run: |
# This is a tag build (releases and prereleases)
# update the tag to include the changelog
git tag -fam "$GITHUB_REF_NAME" "$GITHUB_REF_NAME"
git push --tags --force
- name: Merge to Release branch
if: env.FULL_RELEASE == 'true'
run: |

View file

@ -1,5 +1,25 @@
# Changelog
## [Unreleased](https://github.com/jrnl-org/jrnl/)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.3...HEAD)
**Implemented enhancements:**
- Add `rich` handler to debug logging [\#1627](https://github.com/jrnl-org/jrnl/pull/1627) ([wren](https://github.com/wren))
**Deprecated:**
- Drop Python 3.9 and use Python 3.11 official release [\#1611](https://github.com/jrnl-org/jrnl/pull/1611) ([micahellison](https://github.com/micahellison))
**Build:**
- Fix bug where changelog is always slightly out of date on release tags [\#1631](https://github.com/jrnl-org/jrnl/pull/1631) ([wren](https://github.com/wren))
**Documentation:**
- Document that editors must be blocking processes [\#1624](https://github.com/jrnl-org/jrnl/pull/1624) ([micahellison](https://github.com/micahellison))
## [v3.3](https://pypi.org/project/jrnl/v3.3/) (2022-10-29)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.3-beta2...v3.3)

View file

@ -100,12 +100,12 @@ something like `pip3 install crytography`)
import base64
import getpass
from pathlib import Path
from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
filepath = input("journal file path: ")
password = getpass.getpass("Password: ")
@ -123,7 +123,7 @@ kdf = PBKDF2HMAC(
key = base64.urlsafe_b64encode(kdf.derive(password))
print(Fernet(key).decrypt(ciphertext).decode('utf-8'))
print(Fernet(key).decrypt(ciphertext).decode("utf-8"))
```
**Example for jrnl v1 files**:
@ -137,18 +137,19 @@ like `pip3 install pycrypto`)
"""
import argparse
from Crypto.Cipher import AES
import getpass
import hashlib
from Crypto.Cipher import AES
parser = argparse.ArgumentParser()
parser.add_argument("filepath", help="journal file to decrypt")
args = parser.parse_args()
pwd = getpass.getpass()
key = hashlib.sha256(pwd.encode('utf-8')).digest()
key = hashlib.sha256(pwd.encode("utf-8")).digest()
with open(args.filepath, 'rb') as f:
with open(args.filepath, "rb") as f:
ciphertext = f.read()
crypto = AES.new(key, AES.MODE_CBC, ciphertext[:16])

View file

@ -5,6 +5,8 @@ import logging
import sys
import traceback
from rich.logging import RichHandler
from jrnl.args import parse_args
from jrnl.exception import JrnlException
from jrnl.jrnl import run
@ -21,7 +23,9 @@ def configure_logger(debug=False):
logging.basicConfig(
level=logging.DEBUG,
format="%(levelname)-8s %(name)-12s %(message)s",
datefmt="[%X]",
format="%(message)s",
handlers=[RichHandler()],
)
logging.getLogger("parsedatetime").setLevel(logging.INFO)
logging.getLogger("keyring.backend").setLevel(logging.ERROR)
@ -34,7 +38,7 @@ def cli(manual_args=None):
args = parse_args(manual_args)
configure_logger(args.debug)
logging.debug("Parsed args: %s", args)
logging.debug("Parsed args:\n%s", args)
status_code = run(args)

View file

@ -8,6 +8,7 @@ from typing import Callable
import colorama
import xdg.BaseDirectory
from rich.pretty import pretty_repr
from ruamel.yaml import YAML
from ruamel.yaml import constructor
@ -126,12 +127,15 @@ def scope_config(config, journal_name):
if type(journal_conf) is dict:
# We can override the default config on a by-journal basis
logging.debug(
"Updating configuration with specific journal overrides %s", journal_conf
"Updating configuration with specific journal overrides:\n%s",
pretty_repr(journal_conf),
)
config.update(journal_conf)
else:
# But also just give them a string to point to the journal file
config["journal"] = journal_conf
logging.debug("Scoped config:\n%s", pretty_repr(config))
return config

View file

@ -7,6 +7,8 @@ import logging
import os
import sys
from rich.pretty import pretty_repr
from jrnl.config import DEFAULT_JOURNAL_KEY
from jrnl.config import get_config_path
from jrnl.config import get_default_config
@ -102,7 +104,7 @@ def load_or_install_jrnl(alt_config_path):
logging.debug("Configuration file not found, installing jrnl...")
config = install()
logging.debug('Using configuration "%s"', config)
logging.debug('Using configuration:\n"%s"', pretty_repr(config))
return config

38
poetry.lock generated
View file

@ -237,6 +237,34 @@ mccabe = ">=0.6.0,<0.7.0"
pycodestyle = ">=2.8.0,<2.9.0"
pyflakes = ">=2.4.0,<2.5.0"
[[package]]
name = "flake8-black"
version = "0.3.3"
description = "flake8 plugin to call black as a code style validator"
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
black = ">=22.1.0"
flake8 = ">=3.0.0"
tomli = "*"
[[package]]
name = "flake8-isort"
version = "5.0.0"
description = "flake8 plugin that integrates isort ."
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
flake8 = "*"
isort = ">=4.3.5,<6"
[package.extras]
test = ["pytest"]
[[package]]
name = "flake8-simplify"
version = "0.19.3"
@ -1150,7 +1178,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=
[metadata]
lock-version = "1.1"
python-versions = ">=3.10.0, <3.13"
content-hash = "22d7179ea395349b05b32de694b47746b83f7bfc2e80fd55a39f9b0c1020b092"
content-hash = "c3b4e0ffbe4c6920b1fb773b7eee9d92a78b4950e33b18c94595f3558ec9322e"
[metadata.files]
ansiwrap = [
@ -1343,6 +1371,14 @@ flake8 = [
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
]
flake8-black = [
{file = "flake8-black-0.3.3.tar.gz", hash = "sha256:8211f5e20e954cb57c709acccf2f3281ce27016d4c4b989c3e51f878bb7ce12a"},
{file = "flake8_black-0.3.3-py3-none-any.whl", hash = "sha256:7d667d0059fd1aa468de1669d77cc934b7f1feeac258d57bdae69a8e73c4cd90"},
]
flake8-isort = [
{file = "flake8-isort-5.0.0.tar.gz", hash = "sha256:e336f928c7edc509684930ab124414194b7f4e237c712af8fcbdf49d8747b10c"},
{file = "flake8_isort-5.0.0-py3-none-any.whl", hash = "sha256:c73f9cbd1bf209887f602a27b827164ccfeba1676801b2aa23cb49051a1be79c"},
]
flake8-simplify = [
{file = "flake8_simplify-0.19.3-py3-none-any.whl", hash = "sha256:1057320e9312d75849541fee822900d27bcad05b2405edc84713affee635629e"},
{file = "flake8_simplify-0.19.3.tar.gz", hash = "sha256:2fb083bf5142a98d9c9554755cf2f56f8926eb4a33eae30c0809041b1546879e"},

View file

@ -45,6 +45,8 @@ tzlocal = ">=4.0" # https://github.com/regebro/tzlocal/blob/master/CHANGES.txt
[tool.poetry.dev-dependencies]
black = { version = ">=21.5b2", allow-prereleases = true }
flakeheaven = ">=3.0"
flake8-black = ">=0.3.3"
flake8-isort = ">=5.0.0"
flake8-simplify = ">=0.19"
ipdb = "*"
isort = ">=5.10"
@ -63,26 +65,6 @@ xmltodict = "*"
jrnl = 'jrnl.cli:cli'
[tool.poe.tasks]
format-run = [
{cmd = "black ."},
]
format-check = [
{cmd = "black --version"},
{cmd = "black --check --diff ."},
]
style-check = [
{cmd = "flakeheaven --version"},
{cmd = "flakeheaven plugins"},
{cmd = "flakeheaven lint"},
]
sort-run = [
{cmd = "isort ."},
]
sort-check = [
{cmd = "isort --version"},
{cmd = "isort --check ."},
]
docs-check.default_item_type = "script"
docs-check.sequence = [
"tasks:delete_files(['sitemap.xml', 'config.json'])",
@ -101,22 +83,23 @@ test-run = [
{cmd = "tox -q -e py --"},
]
installer-check = [
{cmd = "poetry --version"},
{cmd = "poetry check"},
# Groups of tasks
format.default_item_type = "cmd"
format.sequence = [
"isort .",
"black .",
]
# Groups of tasks
format = [
"format-run",
"sort-run",
]
lint = [
"installer-check",
"style-check",
"sort-check",
"format-check",
lint.env = { FLAKEHEAVEN_CACHE_TIMEOUT = "0" }
lint.default_item_type = "cmd"
lint.sequence = [
"poetry --version",
"poetry check",
"flakeheaven --version",
"flakeheaven plugins",
"flakeheaven lint",
]
test = [
"lint",
"test-run",
@ -171,6 +154,7 @@ pycodestyle = [
"-W1*", "-W2*", "-W3*", "-W5*",
]
"flake8-*" = ["+*"]
flake8-black = ["-BLK901"]
[build-system]

View file

@ -46,6 +46,22 @@ Feature: Encrypting and decrypting journals
Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good"
Scenario: Encrypt journal twice and get prompted each time
Given we use the config "simple.yaml"
When we run "jrnl --encrypt" and enter
swordfish
swordfish
y
Then we should get no error
And the output should contain "Journal encrypted"
When we run "jrnl --encrypt" and enter
swordfish
swordfish
y
Then we should get no error
And the output should contain "Journal default is already encrypted. Create a new password."
And we should be prompted for a password
And the config for journal "default" should contain "encrypt: true"
Scenario Outline: Running jrnl with encrypt: true on unencryptable journals
Given we use the config "<config_file>"