mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
update upgrade module to use new message handling
This commit is contained in:
parent
cf5b177d1d
commit
cd464eebe0
2 changed files with 13 additions and 2 deletions
|
@ -75,6 +75,8 @@ class MsgText(Enum):
|
|||
|
||||
NoDefaultJournal = "No default journal configured\n{journals}"
|
||||
|
||||
FileDoesNotExist = "{filename} does not exist"
|
||||
|
||||
# --- Journal status ---#
|
||||
JournalNotSaved = "Entry NOT saved to journal"
|
||||
JournalEntryAdded = "Entry added to {journal_name} journal"
|
||||
|
@ -90,6 +92,7 @@ class MsgText(Enum):
|
|||
JournalCreated = "Journal '{journal_name}' created at {filename}"
|
||||
DirectoryCreated = "Directory {directory_name} created"
|
||||
JournalEncrypted = "Journal will be encrypted."
|
||||
BackupCreated = "Created a backup at {filename}"
|
||||
|
||||
# --- Editor ---#
|
||||
WritingEntryStart = """
|
||||
|
|
|
@ -20,7 +20,6 @@ from jrnl.messages import MsgType
|
|||
|
||||
|
||||
def backup(filename, binary=False):
|
||||
print(f" Created a backup at {filename}.backup", file=sys.stderr)
|
||||
filename = os.path.expanduser(os.path.expandvars(filename))
|
||||
|
||||
try:
|
||||
|
@ -29,8 +28,17 @@ def backup(filename, binary=False):
|
|||
|
||||
with open(filename + ".backup", "wb" if binary else "w") as backup:
|
||||
backup.write(contents)
|
||||
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.BackupCreated, MsgType.NORMAL, {"filename": f"filename.backup"}
|
||||
)
|
||||
)
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"\nError: {filename} does not exist.")
|
||||
print_msg(
|
||||
Message(MsgText.FileDoesNotExist, MsgType.WARNING, {"filename": filename})
|
||||
)
|
||||
cont = yesno(f"\nCreate {filename}?", default=False)
|
||||
if not cont:
|
||||
raise JrnlException(Message(MsgText.UpgradeAborted, MsgType.WARNING))
|
||||
|
|
Loading…
Add table
Reference in a new issue