From: Adam Dullage Date: Wed, 22 Nov 2023 13:04:36 +0000 (+0000) Subject: Raise FileNoteFoundError on Note init if applicable X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=8450d2f2e13b57a66f8ddb8731060643b5eb0934;p=flatnotes.git Raise FileNoteFoundError on Note init if applicable --- diff --git a/flatnotes/flatnotes.py b/flatnotes/flatnotes.py index f3e71cb..526ad32 100644 --- a/flatnotes/flatnotes.py +++ b/flatnotes/flatnotes.py @@ -49,9 +49,12 @@ class Note: self._title = title.strip() if not is_valid_filename(self._title): raise InvalidTitleError - if new and os.path.exists(self.filepath): + exists = os.path.exists(self.filepath) + if new and exists: raise FileExistsError - elif new: + if not new and not exists: + raise FileNotFoundError + if new: open(self.filepath, "w").close() @property