blob: 2198a3ba9004ac4a145c33792cfeea9ec68cd894 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.")
|