mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-11 17:46:12 +02:00
replace sys.exit call with new exception handling
This commit is contained in:
parent
c5fc211ae9
commit
548ac582d9
2 changed files with 13 additions and 5 deletions
|
@ -110,9 +110,9 @@ class MsgText(Enum):
|
||||||
https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade
|
https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade
|
||||||
"""
|
"""
|
||||||
|
|
||||||
UpgradeAborted = """
|
UpgradeAborted = "jrnl was NOT upgraded"
|
||||||
jrnl was NOT upgraded
|
|
||||||
"""
|
ImportAborted = "Entries were NOT imported"
|
||||||
|
|
||||||
# -- Config --- #
|
# -- Config --- #
|
||||||
AltConfigNotFound = """
|
AltConfigNotFound = """
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from jrnl.exception import JrnlException
|
||||||
|
from jrnl.messages import Message
|
||||||
|
from jrnl.messages import MsgText
|
||||||
|
from jrnl.messages import MsgType
|
||||||
|
|
||||||
|
|
||||||
class JRNLImporter:
|
class JRNLImporter:
|
||||||
"""This plugin imports entries from other jrnl files."""
|
"""This plugin imports entries from other jrnl files."""
|
||||||
|
@ -22,8 +27,11 @@ class JRNLImporter:
|
||||||
try:
|
try:
|
||||||
other_journal_txt = sys.stdin.read()
|
other_journal_txt = sys.stdin.read()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("[Entries NOT imported into journal.]", file=sys.stderr)
|
raise JrnlException(
|
||||||
sys.exit(0)
|
Message(MsgText.KeyboardInterruptMsg, MsgType.ERROR),
|
||||||
|
Message(MsgText.ImportAborted, MsgType.WARNING),
|
||||||
|
)
|
||||||
|
|
||||||
journal.import_(other_journal_txt)
|
journal.import_(other_journal_txt)
|
||||||
new_cnt = len(journal.entries)
|
new_cnt = len(journal.entries)
|
||||||
print(
|
print(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue