@@ -26,8 +26,10 @@ def __init__(self, dictionary = {}):
26
26
if "Check" in self .dictionary :
27
27
text = self .language_texts ["skipped_diary_slim_day" ]
28
28
29
+ units = self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Units" ]
30
+
29
31
self .today_is_text = text + ":" + "\n " + \
30
- self .day_of_of_text .replace ("Dia " , "" ).format (self .dictionary ["Date" ]["Units " ]["Day" ], self . dictionary [ "Date" ][ " Texts" ]["Month name" ][self .user_language ], self . dictionary [ "Date" ][ "Units" ] ["Year" ])
32
+ self .day_of_of_text .replace ("Dia " , "" ).format (units [ "Day" ], self .dictionary ["Date" ]["Timezone " ]["DateTime" ][ " Texts" ]["Month name" ][self .user_language ], units ["Year" ])
31
33
32
34
print (self .large_bar )
33
35
print ()
@@ -64,7 +66,10 @@ def __init__(self, dictionary = {}):
64
66
print (self .large_bar )
65
67
66
68
def Make_Header (self ):
67
- self .dictionary ["Today is" ] = self .today_is_text_header_prototype .format (self .dictionary ["Date" ]["Texts" ]["Day name" ][self .user_language ], self .dictionary ["Date" ]["Units" ]["Day" ], self .dictionary ["Date" ]["Texts" ]["Month name" ][self .user_language ], self .dictionary ["Date" ]["Units" ]["Year" ])
69
+ units = self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Units" ]
70
+ texts = self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Texts" ]
71
+
72
+ self .dictionary ["Today is" ] = self .today_is_text_header_prototype .format (texts ["Day name" ][self .user_language ], units ["Day" ], texts ["Month name" ][self .user_language ], units ["Year" ])
68
73
69
74
self .dictionary ["Text header" ] = self .text_header_prototype .format (self .current_diary_slim ["Day" ])
70
75
@@ -99,16 +104,17 @@ def Match_Time_Pattern(self, select_text):
99
104
if time != "" and formatted_text not in select_text :
100
105
select_text += formatted_text
101
106
102
- #if self.switches["testing"] == False:
103
- if "Check" in self .dictionary :
104
- print ()
105
- time = self .Input .Type (select_text , first_space = False )
107
+ if self .switches ["testing" ] == False :
108
+ if "Check" in self .dictionary :
109
+ print ()
106
110
107
- if "Check" not in self .dictionary :
108
- print ()
111
+ time = self .Input .Type (select_text , first_space = False )
109
112
110
- #if self.switches["testing"] == True:
111
- time = "00:00"
113
+ if "Check" not in self .dictionary :
114
+ print ()
115
+
116
+ if self .switches ["testing" ] == True :
117
+ time = "00:00"
112
118
113
119
i += 1
114
120
@@ -128,9 +134,10 @@ def Define_Slim_File(self):
128
134
if "Check" not in self .dictionary :
129
135
self .Check_Diary_Slims ()
130
136
131
- print ()
132
- print (self .today_is_text )
133
- print ()
137
+ if "Checked" in self .dictionary :
138
+ print ()
139
+ print (self .today_is_text )
140
+ print ()
134
141
135
142
def Check_Diary_Slims (self ):
136
143
# Define today
@@ -142,7 +149,7 @@ def Check_Diary_Slims(self):
142
149
self .dictionary ["Yesterday" ] = self .Current_Diary_Slim (date = yesterday_date )["Day" ]
143
150
144
151
# Define the Diary Slims list for a more organized code
145
- diary_slims_list = list (self .current_month ["Dictionary " ]["Diary Slims" ].keys ())
152
+ diary_slims_list = list (self .current_month ["Month " ]["Diary Slims" ].keys ())
146
153
147
154
# If yesterday is not inside the Diary Slims list
148
155
# Then the user skipped a Diary Slim
@@ -154,52 +161,56 @@ def Check_Diary_Slims(self):
154
161
# Iterate through the days list
155
162
for day in days_list :
156
163
# Define the date and day text
157
- date = self .Date .Now (self .Date .Date (year = int (self .date ["Units" ]["Year" ]), month = int (self .date ["Units" ]["Month" ]), day = day ))
164
+ units = self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Units" ]
165
+
166
+ date = self .Date .Now (self .Date .Date (year = int (units ["Year" ]), month = int (units ["Month" ]), day = day ))
158
167
159
168
day_text = self .Current_Diary_Slim (date = date )["Day" ]
160
169
161
170
# If the day text is not inside the Diary Slims list
162
171
# And the day is less than the current day
163
- if day_text not in diary_slims_list and day < int (self . date [ "Units" ] ["Day" ]):
172
+ if day_text not in diary_slims_list and day < int (units ["Day" ]):
164
173
# Create the day dictionary
165
174
diary_slims_dictionary [day_text ] = {
166
175
"Day text" : day_text ,
167
176
"Date" : date
168
177
}
169
178
170
- # Create the skipped Diary Slims
171
- if diary_slims_dictionary != {}:
172
- # Define the text to show
173
- text = self .language_texts ["you_skipped_creating_this_diary_slim" ]
179
+ # Create the skipped Diary Slims
180
+ if diary_slims_dictionary != {}:
181
+ # Define the text to show
182
+ text = self .language_texts ["you_skipped_creating_this_diary_slim" ]
174
183
175
- if len (list (diary_slims_dictionary .keys ())) > 1 :
176
- text = self .language_texts ["you_skipped_creating_these_diary_slims" ]
184
+ if len (list (diary_slims_dictionary .keys ())) > 1 :
185
+ text = self .language_texts ["you_skipped_creating_these_diary_slims" ]
177
186
178
- # Show the text
179
- print (text + ":" )
187
+ # Show the text
188
+ print (text + ":" )
180
189
181
- # Show the names of the skipped Diary Slims
182
- for day in diary_slims_dictionary :
183
- day = diary_slims_dictionary [day ]
190
+ # Show the names of the skipped Diary Slims
191
+ for day in diary_slims_dictionary :
192
+ day = diary_slims_dictionary [day ]
184
193
185
- print (day ["Day text" ])
194
+ print (day ["Day text" ])
186
195
187
- print ()
196
+ print ()
188
197
189
- # Create the skipped Diary Slims
190
- for day in diary_slims_dictionary :
191
- day = diary_slims_dictionary [day ]
198
+ # Create the skipped Diary Slims
199
+ for day in diary_slims_dictionary :
200
+ day = diary_slims_dictionary [day ]
192
201
193
- dictionary = {
194
- "Date" : day ["Date" ],
195
- "Check" : True
196
- }
202
+ dictionary = {
203
+ "Date" : day ["Date" ],
204
+ "Check" : True
205
+ }
197
206
198
- Create_New_Diary_Slim (dictionary )
207
+ Create_New_Diary_Slim (dictionary )
199
208
200
- print ()
209
+ print ()
201
210
202
- print (self .large_bar )
211
+ print (self .large_bar )
212
+
213
+ self .dictionary ["Checked" ] = True
203
214
204
215
def Write_To_Files (self ):
205
216
from copy import deepcopy
@@ -218,7 +229,7 @@ def Write_To_Files(self):
218
229
self .current_day_file_text = self .File .Contents (self .dictionary ["File" ])["string" ]
219
230
220
231
# Define the text to write
221
- text_to_write = self .dictionary ["Text header" ] + "\n \n " + self .dictionary ["Date" ]["Formats" ]["HH:MM DD/MM/YYYY" ] + ":\n " + self .dictionary ["Today is" ] + "\n \n " + self .dictionary ["Header" ]
232
+ text_to_write = self .dictionary ["Text header" ] + "\n \n " + self .dictionary ["Date" ]["Timezone" ][ "DateTime" ][ " Formats" ]["HH:MM DD/MM/YYYY" ] + ":\n " + self .dictionary ["Today is" ] + "\n \n " + self .dictionary ["Header" ]
222
233
223
234
# If the file is empty
224
235
if self .current_day_file_text == "" :
@@ -230,10 +241,6 @@ def Write_To_Files(self):
230
241
# Write the header text into the Diary Slim file
231
242
Write_On_Diary_Slim_Module (text_to_write , add_time = False , check_file_length = False , verbose = verbose )
232
243
233
- #if "Check" not in self.dictionary:
234
- # print()
235
- # print(self.dash_space)
236
-
237
244
# Open the Diary Slim file
238
245
self .File .Open (self .dictionary ["File" ])
239
246
@@ -243,34 +250,78 @@ def Write_To_Files(self):
243
250
if self .dictionary ["Diary Slim exists" ] == False :
244
251
day = deepcopy (self .templates ["Day" ])
245
252
253
+ units = self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Units" ]
254
+ texts = self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Texts" ]
255
+
246
256
# Create the Day dictionary
247
- day ["Day" ] = self .dictionary ["Date" ]["Units" ]["Day" ]
248
- day ["Names" ] = self .dictionary ["Date" ]["Texts" ]["Day name" ]
249
- day ["Formats" ]["DD-MM-YYYY" ] = self .dictionary ["Date" ]["Formats" ]["DD-MM-YYYY" ]
250
- day ["Creation time" ]["HH:MM" ] = self .dictionary ["Date" ]["Formats" ]["HH:MM" ]
251
- day ["Creation time" ]["Hours" ] = self .dictionary ["Date" ]["Units" ]["Hour" ]
252
- day ["Creation time" ]["Minutes" ] = self .dictionary ["Date" ]["Units" ]["Minute" ]
253
- day ["Data" ]["Sleep times" ] = {
254
- "Slept" : self .dictionary ["Sleeping time" ],
255
- "Woke up" : self .dictionary ["Waking time" ]
257
+ day = {
258
+ "Day" : units ["Day" ],
259
+ "Names" : texts ["Day name" ],
260
+ "Formats" : {
261
+ "DD-MM-YYYY" : self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Formats" ]["DD-MM-YYYY" ],
262
+ },
263
+ "Creation time" : {
264
+ "HH:MM" : self .dictionary ["Date" ]["Timezone" ]["DateTime" ]["Formats" ]["HH:MM" ],
265
+ "Hours" : units ["Hour" ],
266
+ "Minutes" : units ["Minute" ]
267
+ }
256
268
}
257
269
270
+ # Check if the sleep times items are inside the dictionary
271
+ keys = [
272
+ "Slept" ,
273
+ "Woke up"
274
+ ]
275
+
276
+ i = 0
277
+ for item in ["Sleeping" , "Waking" ]:
278
+ item = item + " time"
279
+
280
+ # If the item is inisde the dictionary
281
+ if item in self .dictionary :
282
+ # Create the data dictionary if it does not exist
283
+ if "Data" not in day :
284
+ day ["Data" ] = {
285
+ "Sleep times" : {}
286
+ }
287
+
288
+ # Add the sleep time to the Day dictionary
289
+ day ["Data" ]["Sleep times" ][keys [i ]] = self .dictionary [item ]
290
+
291
+ i += 1
292
+
258
293
# Edit the Month dictionary
259
294
key = self .current_diary_slim ["Day" ]
260
295
261
- # Add to the Diary Slims dictionary
262
- self .current_month ["Dictionary" ]["Diary Slims" ][key ] = day
296
+ # Add to the "Diary Slims" dictionary inside the Month dictionary
297
+ self .current_month ["Month" ]["Diary Slims" ][key ] = day
298
+
299
+ # Update the month "Diary Slims" number inside the Month dictionary
300
+ self .current_month ["Month" ]["Numbers" ]["Diary Slims" ] = len (list (self .current_month ["Month" ]["Diary Slims" ].keys ()))
301
+
302
+ verbose = False
263
303
264
- # Update the "Diary Slims" number
265
- self .current_month ["Dictionary" ][ "Numbers" ][ "Diary Slims" ] = len ( list ( self .current_month ["Dictionary" ][ "Diary Slims" ]. keys ()) )
304
+ # Edit the "Month.json" file with the new Month dictionary
305
+ self .JSON . Edit ( self . current_month ["File" ], self .current_month ["Month" ], verbose = verbose )
266
306
267
- # Edit the "Month.json" file
268
- self .JSON .Edit (self .current_month ["File" ], self .current_month ["Dictionary" ], verbose = False )
307
+ # ----- #
308
+
309
+ # Edit the Year dictionary
269
310
270
311
# Update the Month dictionary inside the Year dictionary
271
- self .current_year ["Year" ]["Months" ][self .current_month ["Name" ]] = self .current_month ["Dictionary" ]
312
+ self .current_year ["Year" ]["Months" ][self .current_month ["Name" ]] = self .current_month ["Month" ]
313
+
314
+ # Update the "Months" number inside the Year dictionary
315
+ self .current_year ["Year" ]["Numbers" ]["Months" ] = len (list (self .current_year ["Year" ]["Months" ].keys ()))
316
+
317
+ # Update the Year "Diary Slims" number inside the Year dictionary
318
+ self .current_year ["Year" ]["Numbers" ]["Diary Slims" ] = 0
319
+
320
+ # Iterate through the Months list to add to the Year "Diary Slims" number
321
+ for month in self .current_year ["Year" ]["Months" ].values ():
322
+ self .current_year ["Year" ]["Numbers" ]["Diary Slims" ] += month ["Numbers" ]["Diary Slims" ]
272
323
273
- # Edit the "Year.json" file
274
- self .JSON .Edit (self .folders ["diary_slim" ]["current_year" ]["year" ], self .current_year ["Year" ], verbose = False )
324
+ # Edit the "Year.json" file with the new Year dictionary
325
+ self .JSON .Edit (self .folders ["diary_slim" ]["current_year" ]["year" ], self .current_year ["Year" ], verbose = verbose )
275
326
276
327
super ().__init__ ()
0 commit comments