mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
fix merge errors
This commit is contained in:
parent
2051f04839
commit
66ce8debe5
8 changed files with 74 additions and 100 deletions
|
@ -22,7 +22,10 @@ from .Journal import LegacyJournal
|
|||
from .prompt import create_password
|
||||
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.exception import JrnlExceptionMessage
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.messages import MsgType
|
||||
|
||||
|
||||
|
||||
def make_key(password):
|
||||
|
@ -58,7 +61,7 @@ def decrypt_content(
|
|||
attempt += 1
|
||||
|
||||
if result is None:
|
||||
raise JrnlException(JrnlExceptionMessage.PasswordMaxTriesExceeded)
|
||||
raise JrnlException(Message(MsgText.PasswordMaxTriesExceeded, MsgType.ERROR))
|
||||
|
||||
return result
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ def cli(manual_args=None):
|
|||
|
||||
except JrnlException as e:
|
||||
status_code = 1
|
||||
print_msg(e.title, e.message, msg=Message.ERROR)
|
||||
e.print()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
status_code = 1
|
||||
|
|
|
@ -5,8 +5,6 @@ import sys
|
|||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from jrnl.color import ERROR_COLOR
|
||||
from jrnl.color import RESET_COLOR
|
||||
from jrnl.os_compat import on_windows
|
||||
from jrnl.os_compat import split_args
|
||||
from jrnl.output import print_msg
|
||||
|
@ -33,7 +31,7 @@ def get_text_from_editor(config, template=""):
|
|||
subprocess.call(split_args(config["editor"]) + [tmpfile])
|
||||
except FileNotFoundError:
|
||||
raise JrnlException(
|
||||
JrnlExceptionMessage.EditorMisconfigured, editor_key=config["editor"]
|
||||
Message(MsgText.EditorMisconfigured, MsgType.ERROR, { "editor_key": config["editor"] })
|
||||
)
|
||||
|
||||
with open(tmpfile, "r", encoding="utf-8") as f:
|
||||
|
@ -41,7 +39,7 @@ def get_text_from_editor(config, template=""):
|
|||
os.remove(tmpfile)
|
||||
|
||||
if not raw:
|
||||
raise JrnlException(JrnlExceptionMessage.NoTextReceived)
|
||||
raise JrnlException(Message(MsgText.NoTextReceived, MsgType.ERROR))
|
||||
|
||||
return raw
|
||||
|
||||
|
|
|
@ -3,91 +3,6 @@
|
|||
from jrnl.messages import Message
|
||||
from jrnl.output import print_msg
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class JrnlExceptionMessage(Enum):
|
||||
ConfigDirectoryIsFile = """
|
||||
The path to your jrnl configuration directory is a file, not a directory:
|
||||
|
||||
{config_directory_path}
|
||||
|
||||
Removing this file will allow jrnl to save its configuration.
|
||||
"""
|
||||
|
||||
LineWrapTooSmallForDateFormat = """
|
||||
The provided linewrap value of {config_linewrap} is too small by
|
||||
{columns} columns to display the timestamps in the configured time
|
||||
format for journal {journal}.
|
||||
|
||||
You can avoid this error by specifying a linewrap value that is larger
|
||||
by at least {columns} in the configuration file or by using
|
||||
--config-override at the command line
|
||||
"""
|
||||
|
||||
CannotEncryptJournalType = """
|
||||
The journal {journal_name} can't be encrypted because it is a
|
||||
{journal_type} journal.
|
||||
|
||||
To encrypt it, create a new journal referencing a file, export
|
||||
this journal to the new journal, then encrypt the new journal.
|
||||
"""
|
||||
|
||||
KeyboardInterrupt = "Aborted by user"
|
||||
|
||||
EditorMisconfigured = """
|
||||
No such file or directory: '{editor_key}'
|
||||
|
||||
Please check the 'editor' key in your config file for errors:
|
||||
editor: '{editor_key}'
|
||||
"""
|
||||
|
||||
JournalFailedUpgrade = """
|
||||
The following journal{s} failed to upgrade:
|
||||
{failed_journals}
|
||||
|
||||
Please tell us about this problem at the following URL:
|
||||
https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade
|
||||
"""
|
||||
|
||||
NothingToDelete = """
|
||||
No entries to delete, because the search returned no results.
|
||||
"""
|
||||
|
||||
NoTextReceived = """
|
||||
Nothing saved to file.
|
||||
"""
|
||||
|
||||
UpgradeAborted = """
|
||||
jrnl was NOT upgraded
|
||||
"""
|
||||
|
||||
EditorNotConfigured = """
|
||||
There is no editor configured.
|
||||
|
||||
To use the --edit option, please specify an editor your config file:
|
||||
{config_file}
|
||||
|
||||
For examples of how to configure an external editor, see:
|
||||
https://jrnl.sh/en/stable/external-editors/
|
||||
"""
|
||||
|
||||
AltConfigNotFound = """
|
||||
Alternate configuration file not found at the given path:
|
||||
{config_file}
|
||||
"""
|
||||
|
||||
PasswordMaxTriesExceeded = """
|
||||
Too many attempts with wrong password.
|
||||
"""
|
||||
|
||||
SomeTest = """
|
||||
Some error or something
|
||||
|
||||
This is a thing to test with this message or whatever and maybe it just
|
||||
keeps going forever because it's super long for no apparent reason
|
||||
"""
|
||||
|
||||
|
||||
class JrnlException(Exception):
|
||||
"""Common exceptions raised by jrnl."""
|
||||
|
|
|
@ -18,7 +18,10 @@ from .prompt import yesno
|
|||
from .upgrade import is_old_version
|
||||
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.exception import JrnlExceptionMessage
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.messages import MsgType
|
||||
|
||||
|
||||
|
||||
def upgrade_config(config_data, alt_config_path=None):
|
||||
|
@ -51,7 +54,7 @@ def find_default_config():
|
|||
def find_alt_config(alt_config):
|
||||
if not os.path.exists(alt_config):
|
||||
raise JrnlException(
|
||||
JrnlExceptionMessage.AltConfigNotFound, config_file=alt_config
|
||||
Message(MsgText.AltConfigNotFound, MsgType.ERROR, { "config_file": alt_config })
|
||||
)
|
||||
|
||||
return alt_config
|
||||
|
|
|
@ -16,7 +16,9 @@ from . import time
|
|||
from .override import apply_overrides
|
||||
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.exception import JrnlExceptionMessage
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.messages import MsgType
|
||||
|
||||
|
||||
def run(args):
|
||||
|
@ -134,7 +136,7 @@ def write_mode(args, config, journal, **kwargs):
|
|||
|
||||
if not raw:
|
||||
logging.error("Write mode: couldn't get raw text")
|
||||
raise JrnlException(JrnlExceptionMessage.NoTextReceived)
|
||||
raise JrnlException(Message(MsgText.JrnlExceptionMessage.NoTextReceived, MsgType.ERROR))
|
||||
|
||||
logging.debug(
|
||||
'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw
|
||||
|
@ -240,7 +242,7 @@ def _edit_search_results(config, journal, old_entries, **kwargs):
|
|||
"""
|
||||
if not config["editor"]:
|
||||
raise JrnlException(
|
||||
JrnlExceptionMessage.EditorNotConfigured, config_file=get_config_path()
|
||||
Message(MsgText.EditorNotConfigured, MsgType.ERROR, {"config_file": get_config_path()})
|
||||
)
|
||||
|
||||
# separate entries we are not editing
|
||||
|
|
|
@ -72,6 +72,56 @@ class MsgText(Enum):
|
|||
HowToQuitWindows = "Ctrl+z and then Enter"
|
||||
HowToQuitLinux = "Ctrl+d"
|
||||
|
||||
EditorMisconfigured = """
|
||||
No such file or directory: '{editor_key}'
|
||||
|
||||
Please check the 'editor' key in your config file for errors:
|
||||
editor: '{editor_key}'
|
||||
"""
|
||||
|
||||
EditorNotConfigured = """
|
||||
There is no editor configured
|
||||
|
||||
To use the --edit option, please specify an editor your config file:
|
||||
{config_file}
|
||||
|
||||
For examples of how to configure an external editor, see:
|
||||
https://jrnl.sh/en/stable/external-editors/
|
||||
"""
|
||||
|
||||
NoTextReceived = """
|
||||
Nothing saved to file
|
||||
"""
|
||||
|
||||
# --- Upgrade --- #
|
||||
JournalFailedUpgrade = """
|
||||
The following journal{s} failed to upgrade:
|
||||
{failed_journals}
|
||||
|
||||
Please tell us about this problem at the following URL:
|
||||
https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade
|
||||
"""
|
||||
|
||||
UpgradeAborted = """
|
||||
jrnl was NOT upgraded
|
||||
"""
|
||||
|
||||
# -- Config --- #
|
||||
AltConfigNotFound = """
|
||||
Alternate configuration file not found at the given path:
|
||||
{config_file}
|
||||
"""
|
||||
|
||||
# --- Password --- #
|
||||
PasswordMaxTriesExceeded = """
|
||||
Too many attempts with wrong password
|
||||
"""
|
||||
|
||||
# --- Search --- #
|
||||
NothingToDelete = """
|
||||
No entries to delete, because the search returned no results
|
||||
"""
|
||||
|
||||
|
||||
class Message(NamedTuple):
|
||||
text: MsgText
|
||||
|
|
|
@ -13,9 +13,12 @@ from .config import scope_config
|
|||
from .prompt import yesno
|
||||
|
||||
from jrnl.output import print_msg
|
||||
from jrnl.output import Message
|
||||
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.exception import JrnlExceptionMessage
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.messages import MsgType
|
||||
|
||||
|
||||
|
||||
def backup(filename, binary=False):
|
||||
|
@ -32,7 +35,7 @@ def backup(filename, binary=False):
|
|||
print(f"\nError: {filename} does not exist.")
|
||||
cont = yesno(f"\nCreate {filename}?", default=False)
|
||||
if not cont:
|
||||
raise JrnlException(JrnlExceptionMessage.UpgradeAborted)
|
||||
raise JrnlException(Message(MsgText.UpgradeAborted), MsgType.WARNING)
|
||||
|
||||
|
||||
def check_exists(path):
|
||||
|
|
Loading…
Add table
Reference in a new issue