mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 19:48:31 +02:00
reformat with black
This commit is contained in:
parent
548ac582d9
commit
4a4a874f9f
6 changed files with 28 additions and 9 deletions
|
@ -27,7 +27,6 @@ from jrnl.messages import MsgText
|
||||||
from jrnl.messages import MsgType
|
from jrnl.messages import MsgType
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def make_key(password):
|
def make_key(password):
|
||||||
password = password.encode("utf-8")
|
password = password.encode("utf-8")
|
||||||
kdf = PBKDF2HMAC(
|
kdf = PBKDF2HMAC(
|
||||||
|
|
|
@ -198,7 +198,11 @@ def get_journal_name(args, config):
|
||||||
|
|
||||||
if args.journal_name not in config["journals"]:
|
if args.journal_name not in config["journals"]:
|
||||||
raise JrnlException(
|
raise JrnlException(
|
||||||
Message(MsgText.NoDefaultJournal, MsgType.ERROR, { "journals": list_journals(config)}),
|
Message(
|
||||||
|
MsgText.NoDefaultJournal,
|
||||||
|
MsgType.ERROR,
|
||||||
|
{"journals": list_journals(config)},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.debug("Using journal name: %s", args.journal_name)
|
logging.debug("Using journal name: %s", args.journal_name)
|
||||||
|
|
|
@ -31,7 +31,11 @@ def get_text_from_editor(config, template=""):
|
||||||
subprocess.call(split_args(config["editor"]) + [tmpfile])
|
subprocess.call(split_args(config["editor"]) + [tmpfile])
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise JrnlException(
|
raise JrnlException(
|
||||||
Message(MsgText.EditorMisconfigured, MsgType.ERROR, { "editor_key": config["editor"] })
|
Message(
|
||||||
|
MsgText.EditorMisconfigured,
|
||||||
|
MsgType.ERROR,
|
||||||
|
{"editor_key": config["editor"]},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(tmpfile, "r", encoding="utf-8") as f:
|
with open(tmpfile, "r", encoding="utf-8") as f:
|
||||||
|
|
|
@ -23,7 +23,6 @@ from jrnl.messages import MsgText
|
||||||
from jrnl.messages import MsgType
|
from jrnl.messages import MsgType
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade_config(config_data, alt_config_path=None):
|
def upgrade_config(config_data, alt_config_path=None):
|
||||||
"""Checks if there are keys missing in a given config dict, and if so, updates the config file accordingly.
|
"""Checks if there are keys missing in a given config dict, and if so, updates the config file accordingly.
|
||||||
This essentially automatically ports jrnl installations if new config parameters are introduced in later
|
This essentially automatically ports jrnl installations if new config parameters are introduced in later
|
||||||
|
@ -54,7 +53,9 @@ def find_default_config():
|
||||||
def find_alt_config(alt_config):
|
def find_alt_config(alt_config):
|
||||||
if not os.path.exists(alt_config):
|
if not os.path.exists(alt_config):
|
||||||
raise JrnlException(
|
raise JrnlException(
|
||||||
Message(MsgText.AltConfigNotFound, MsgType.ERROR, { "config_file": alt_config })
|
Message(
|
||||||
|
MsgText.AltConfigNotFound, MsgType.ERROR, {"config_file": alt_config}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return alt_config
|
return alt_config
|
||||||
|
|
18
jrnl/jrnl.py
18
jrnl/jrnl.py
|
@ -136,7 +136,9 @@ def write_mode(args, config, journal, **kwargs):
|
||||||
|
|
||||||
if not raw:
|
if not raw:
|
||||||
logging.error("Write mode: couldn't get raw text")
|
logging.error("Write mode: couldn't get raw text")
|
||||||
raise JrnlException(Message(MsgText.JrnlExceptionMessage.NoTextReceived, MsgType.ERROR))
|
raise JrnlException(
|
||||||
|
Message(MsgText.JrnlExceptionMessage.NoTextReceived, MsgType.ERROR)
|
||||||
|
)
|
||||||
|
|
||||||
logging.debug(
|
logging.debug(
|
||||||
'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw
|
'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw
|
||||||
|
@ -200,7 +202,13 @@ def _get_editor_template(config, **kwargs):
|
||||||
logging.debug("Write mode: template loaded: %s", template)
|
logging.debug("Write mode: template loaded: %s", template)
|
||||||
except OSError:
|
except OSError:
|
||||||
logging.error("Write mode: template not loaded")
|
logging.error("Write mode: template not loaded")
|
||||||
raise JrnlException(Message(MsgText.CantReadTemplate, MsgType.ERROR, { "template": config["template"] }))
|
raise JrnlException(
|
||||||
|
Message(
|
||||||
|
MsgText.CantReadTemplate,
|
||||||
|
MsgType.ERROR,
|
||||||
|
{"template": config["template"]},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return template
|
return template
|
||||||
|
|
||||||
|
@ -238,7 +246,11 @@ def _edit_search_results(config, journal, old_entries, **kwargs):
|
||||||
"""
|
"""
|
||||||
if not config["editor"]:
|
if not config["editor"]:
|
||||||
raise JrnlException(
|
raise JrnlException(
|
||||||
Message(MsgText.EditorNotConfigured, MsgType.ERROR, {"config_file": get_config_path()})
|
Message(
|
||||||
|
MsgText.EditorNotConfigured,
|
||||||
|
MsgType.ERROR,
|
||||||
|
{"config_file": get_config_path()},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# separate entries we are not editing
|
# separate entries we are not editing
|
||||||
|
|
|
@ -20,7 +20,6 @@ from jrnl.messages import MsgText
|
||||||
from jrnl.messages import MsgType
|
from jrnl.messages import MsgType
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def backup(filename, binary=False):
|
def backup(filename, binary=False):
|
||||||
print(f" Created a backup at {filename}.backup", file=sys.stderr)
|
print(f" Created a backup at {filename}.backup", file=sys.stderr)
|
||||||
filename = os.path.expanduser(os.path.expandvars(filename))
|
filename = os.path.expanduser(os.path.expandvars(filename))
|
||||||
|
|
Loading…
Add table
Reference in a new issue