@@ -10,8 +10,6 @@ class Create_New_Diary_Slim(Diary_Slim):
10
10
def __init__ (self ):
11
11
super ().__init__ ()
12
12
13
- self .Define_Times ()
14
-
15
13
print ()
16
14
print (self .large_bar )
17
15
print ()
@@ -40,14 +38,10 @@ def __init__(self):
40
38
print ()
41
39
print (self .large_bar )
42
40
43
- def Define_Times (self ):
44
- self .date = self .Date .Now ()
45
-
46
- self .file_name_string = "{} {}, {}" .format (self .Text .Add_Leading_Zeroes (self .date ["Units" ]["Day" ]), self .date ["Texts" ]["Day name" ][self .user_language ], self .date ["Formats" ]["DD-MM-YYYY" ])
47
-
48
41
def Make_Header (self ):
49
42
self .today_is = self .today_is_text_header_prototype .format (self .date ["Texts" ]["Day name" ][self .user_language ], self .date ["Units" ]["Day" ], self .date ["Texts" ]["Month name" ][self .user_language ], self .date ["Units" ]["Year" ])
50
- self .text_header = self .text_header_prototype .format (self .file_name_string )
43
+
44
+ self .text_header = self .text_header_prototype .format (self .current_day )
51
45
52
46
self .select_text = self .language_texts ["type_the_time_that_you_{}" ].format (self .language_texts ["have_gone_to_sleep" ])
53
47
self .sleeping_time = self .Match_Time_Pattern (self .select_text )
@@ -85,23 +79,23 @@ def Define_Slim_File(self):
85
79
self .diary_slim_exists = False
86
80
87
81
# Current day file
88
- self . current_day_file = self .current_month_folder + self . file_name_string + ".txt"
82
+ current_month = list ( self .current_year [ "Year" ][ "Months" ]. keys ())[ - 1 ]
89
83
90
- if self .File .Exist (self .current_day_file ) == True :
84
+ if self .File .Exist (self .current_year [ "File" ] ) == True :
91
85
self .diary_slim_exists = True
92
86
93
- if self .File .Exist (self .current_day_file ) == False :
94
- self .File .Create (self .current_day_file )
87
+ if self .File .Exist (self .current_year [ "File" ] ) == False :
88
+ self .File .Create (self .current_year [ "File" ] )
95
89
96
90
def Write_To_Files (self ):
91
+ from copy import deepcopy
92
+
93
+ # Write the header text
97
94
if self .diary_slim_exists == False :
98
95
print (self .dash_space )
99
96
print ()
100
97
101
- self .current_day_file_text = self .File .Contents (self .current_day_file )["string" ]
102
-
103
- if self .current_day_file_text == "" :
104
- self .File .Edit (self .current_diary_slim_file , self .current_day_file , "w" )
98
+ self .current_day_file_text = self .File .Contents (self .current_year ["File" ])["string" ]
105
99
106
100
text_to_write = self .text_header + "\n \n " + self .Date .Now ()["Formats" ]["HH:MM DD/MM/YYYY" ] + ":\n " + self .today_is + "\n \n " + self .header
107
101
@@ -111,38 +105,41 @@ def Write_To_Files(self):
111
105
print ()
112
106
print (self .dash_space )
113
107
114
- self .File .Open (self .current_day_file )
108
+ # Open the Diary Slim file
109
+ self .File .Open (self .current_year ["File" ])
115
110
116
111
# ----- #
117
112
118
113
if self .diary_slim_exists == False :
119
- # Year folders.txt
120
- text_to_append = str (self .date ["Units" ]["Year" ]) + "/"
121
-
122
- self .File .Edit (self .year_folders_file , text_to_append , "a" )
114
+ day = deepcopy (self .templates ["Day" ])
123
115
124
- # Month folders.txt
125
- text_to_append = str (self .month_folder_name + "/" )
116
+ # Create the Day dictionary
117
+ day ["Day" ] = self .date ["Units" ]["Day" ]
118
+ day ["Names" ] = self .date ["Texts" ]["Day name" ]
119
+ day ["Formats" ]["DD-MM-YYYY" ] = self .date ["Formats" ]["DD-MM-YYYY" ]
120
+ day ["Creation time" ]["HH:MM" ] = self .date ["Formats" ]["HH:MM" ]
121
+ day ["Creation time" ]["Hours" ] = self .date ["Units" ]["Hour" ]
122
+ day ["Creation time" ]["Minutes" ] = self .date ["Units" ]["Minute" ]
123
+ day ["Data" ]["Sleep times" ] = {
124
+ "Slept" : self .sleeping_time ,
125
+ "Woke up" : self .waking_time
126
+ }
126
127
127
- self .File .Edit (self .month_folders_file , text_to_append , "a" )
128
+ # Edit the Month dictionary
129
+ key = self .current_day
128
130
129
- # File names.txt
130
- text_to_append = self . file_name_string
131
+ # Add to the Diary Slims dictionary
132
+ self . current_year [ "Month" ][ "Dictionary" ][ "Diary Slims" ][ key ] = day
131
133
132
- if text_to_append not in self . File . Contents ( self . file_names_file )[ "lines" ]:
133
- self .File . Edit ( self .file_names_file , text_to_append , "a" )
134
+ # Update the "Diary Slims" number
135
+ self .current_year [ "Month" ][ "Dictionary" ][ "Numbers" ][ "Diary Slims" ] = len ( list ( self .current_year [ "Month" ][ "Dictionary" ][ "Diary Slims" ]. keys ()) )
134
136
135
- # ----- #
136
-
137
- if self .diary_slim_exists == False :
138
- text_to_append = self .file_name_string
137
+ # Edit the "Month.json" file
138
+ self .JSON .Edit (self .current_year ["Month" ]["File" ], self .current_year ["Month" ]["Dictionary" ])
139
139
140
- # [Year]/Year file names.txt
141
- if text_to_append not in self .File .Contents (self .current_year_file_names_file )["lines" ]:
142
- self .File .Edit (self .current_year_file_names_file , text_to_append , "a" )
140
+ # Edit the "Year.json" file
141
+ self .current_year ["Year" ]["Months" ][self .current_year ["Month" ]["Name" ]] = self .current_year ["Month" ]["Dictionary" ]
143
142
144
- # [Year]/[Month]/Month file names.txt
145
- if text_to_append not in self .File .Contents (self .current_month_file_names_file )["lines" ]:
146
- self .File .Edit (self .current_month_file_names_file , text_to_append , "a" )
143
+ self .JSON .Edit (self .folders ["diary_slim" ]["current_year" ]["year" ], self .current_year ["Year" ])
147
144
148
- # ----- #
145
+ super (). __init__ ()
0 commit comments