git.99rst.org
/
flatnotes.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
| inline |
side by side
(parent:
b631971
)
Raise FileNoteFoundError on Note init if applicable
author
Adam Dullage
<redacted>
Wed, 22 Nov 2023 13:04:36 +0000
(13:04 +0000)
committer
Adam Dullage
<redacted>
Wed, 22 Nov 2023 13:04:36 +0000
(13:04 +0000)
flatnotes/flatnotes.py
patch
|
blob
|
history
diff --git
a/flatnotes/flatnotes.py
b/flatnotes/flatnotes.py
index f3e71cb56433b389694fbbe7858e1415544abf03..526ad325b775d2c27856407c1bb8a56476980159 100644
(file)
--- 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
git clone https://git.99rst.org/PROJECT