From 9cde3624920cb1ddd563b8addfcc65ccc79e080a Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Wed, 19 Feb 2025 20:35:50 -0500 Subject: Finish refactor --- note_tools/tomorrow.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 note_tools/tomorrow.py (limited to 'note_tools/tomorrow.py') diff --git a/note_tools/tomorrow.py b/note_tools/tomorrow.py new file mode 100644 index 0000000..2198a3b --- /dev/null +++ b/note_tools/tomorrow.py @@ -0,0 +1,27 @@ +from . import NoteBaseCommand +import os +from datetime import timedelta +import sublime +import sublime_plugin + +class NewNoteForTomorrowCommand(NoteBaseCommand, sublime_plugin.WindowCommand): + def run(self): + self.date = self.get_date() + timedelta(days=1) + + notes_path = self.get_notes_path(self.window.project_data()) + + if notes_path: + year, month = self.get_date_parts() + directory = os.path.join(notes_path, year, month) + os.makedirs(directory, exist_ok=True) + file_path = os.path.join(directory, self.file_name()) + + # Check if file already exists + if os.path.exists(file_path): + sublime.message_dialog(f"The file '{self.file_name()}' already exists.") + else: + self.write_file_heading(file_path) + + else: + sublime.message_dialog("No 'Notes' directory found in the project. Please add a 'Notes' folder.") + -- cgit v1.1