mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
Format code a bit nicer
This commit is contained in:
parent
7ac104a60d
commit
b0f437f345
2 changed files with 22 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
|||
# Copyright (C) 2012-2021 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
import textwrap
|
||||
|
||||
|
||||
class UserAbort(Exception):
|
||||
|
@ -17,14 +18,19 @@ class JrnlError(Exception):
|
|||
|
||||
def __init__(self, error_type, **kwargs):
|
||||
self.error_type = error_type
|
||||
self.message = self.get_error_message(**kwargs)
|
||||
|
||||
def get_error_message(self, **kwargs):
|
||||
self.message = self._get_error_message(**kwargs)
|
||||
|
||||
def _get_error_message(self, **kwargs):
|
||||
error_messages = {
|
||||
"ConfigDirectoryIsFile": "The path to your jrnl configuration directory is a file, not a directory:\n"
|
||||
+ "{config_directory_path}\n"
|
||||
+ "Removing this file will allow jrnl to save its configuration."
|
||||
"ConfigDirectoryIsFile": textwrap.dedent(
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
return error_messages[self.error_type].format(**kwargs)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import textwrap
|
||||
|
||||
from jrnl.exception import JrnlError
|
||||
|
||||
|
||||
|
@ -6,8 +8,12 @@ def test_config_directory_exception_message():
|
|||
"ConfigDirectoryIsFile", config_directory_path="/config/directory/path"
|
||||
)
|
||||
|
||||
assert ex.message == (
|
||||
"The path to your jrnl configuration directory is a file, not a directory:\n"
|
||||
+ "/config/directory/path\n"
|
||||
+ "Removing this file will allow jrnl to save its configuration."
|
||||
assert ex.message == textwrap.dedent(
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue