Skip to content

Commit 87e83b4

Browse files
committed
On the "Diary_Slim" module, I re-wrote it to use the new JSON format of the database, to register the years, months, and days.
It registers the information about the year, month, days, and Diary Slim files inside JSON files. The "Year.json" file contains the year number, months number, year days number, and year Diary Slims number. It also contains the "Months" dictionary that includes the months' dictionaries. There is also the "Month.json" file which contains the year number, month number, month days number, month Diary Slims number, and month names and formats. It also contains the "Diary Slims" dictionary that includes the Diary Slims dictionaries. The "Diary Slim" dictionaries contain the day number and names, formats, creation time, hours and minutes of creation time, and data (like sleep times).
1 parent ba02237 commit 87e83b4

File tree

35 files changed

+868
-363
lines changed

35 files changed

+868
-363
lines changed

Configurações.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"Idioma": "pt"
3+
}

Module Files/Code/Texts.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@
140140
"pt": "Você terminou de atualizar o site",
141141
"en": "You finished updating the website"
142142
},
143-
"you_finished_updating_the_websites": {
144-
"pt": "Você terminou de atualizar os sites",
145-
"en": "You finished updating the websites"
143+
"you_finished_updating_these_websites": {
144+
"pt": "Você terminou de atualizar estes sites",
145+
"en": "You finished updating these websites"
146146
}
147147
}

Module Files/Food_Time/Times.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"Will be hungry": 3
1111
},
1212
"Ate": {
13-
"Object": "2023-05-22 13:19:38-03:00",
13+
"Object": "2023-05-28 13:11:35-03:00",
1414
"Time": 0,
15-
"Time text": "13:19",
15+
"Time text": "13:11",
1616
"Unit": {
1717
"en": "hours",
1818
"pt": "horas"
@@ -23,9 +23,9 @@
2323
}
2424
},
2525
"Can drink water": {
26-
"Object": "2023-05-22 13:59:38-03:00",
26+
"Object": "2023-05-28 13:51:35-03:00",
2727
"Time": 40,
28-
"Time text": "13:59",
28+
"Time text": "13:51",
2929
"Unit": {
3030
"en": "minutes",
3131
"pt": "minutos"
@@ -36,9 +36,9 @@
3636
}
3737
},
3838
"Will be hungry": {
39-
"Object": "2023-05-22 16:19:38-03:00",
39+
"Object": "2023-05-28 16:11:35-03:00",
4040
"Time": 3,
41-
"Time text": "16:19",
41+
"Time text": "16:11",
4242
"Unit": {
4343
"en": "hours",
4444
"pt": "horas"

Module Files/Tasks/Texts.json

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
"en": "Done tasks",
8080
"pt": "Tarefas feitas"
8181
},
82+
"completed_tasks": {
83+
"en": "Completed tasks",
84+
"pt": "Tarefas concluídas"
85+
},
8286
"first_task_in_year": {
8387
"en": "First task in year",
8488
"pt": "Primeira tarefa no ano"

Module Files/Utility/Date/Texts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"March",
8585
"April",
8686
"May",
87-
"Jun",
87+
"June",
8888
"July",
8989
"August",
9090
"September",
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"testing": false,
3-
"verbose": false,
2+
"testing": true,
3+
"verbose": true,
44
"user_information": false
55
}

Module Files/Utility/Language/Texts.json

+8
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@
597597
"en": "First {} in year",
598598
"pt": "Primeiro {} no ano"
599599
},
600+
"first_{}_in_year, feminine": {
601+
"en": "First {} in year",
602+
"pt": "Primeira {} no ano"
603+
},
600604
"first_entry_in_year": {
601605
"en": "First entry in year",
602606
"pt": "Primeira entrada no ano"
@@ -970,6 +974,10 @@
970974
"en": "Add more",
971975
"pt": "Adicionar mais"
972976
},
977+
"general, title()": {
978+
"en": "General",
979+
"pt": "Geral"
980+
},
973981
"genders, type: dict": {
974982
"en": {
975983
"masculine": {

Modules/Code/Update_Websites/__init__.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -53,39 +53,39 @@ def __init__(self, update_one_website = False, module_website = None):
5353
print(self.large_bar)
5454
print()
5555

56-
text = self.language_texts["you_finished_updating_the_website"]
56+
text = self.language_texts["you_finished_updating_the_website"] + ' "' + self.websites[self.user_language][0] + '".'
5757

5858
if len(self.websites["update"]) > 1:
59-
text = self.language_texts["you_finished_updating_the_websites"]
59+
text = self.language_texts["you_finished_updating_these_websites"] + ":" + "\n"
6060

61-
print(text + ".")
61+
for website in self.websites["update"]:
62+
text += website
63+
64+
if website != list(self.websites["update"].keys())[-1]:
65+
text += "\n"
66+
67+
print(text)
6268

6369
def Define_Variables(self):
6470
self.small_languages_backup = self.languages["small"].copy()
6571

66-
self.languages = [
67-
"general",
68-
self.languages["full_translated"]["en"]["en"],
69-
self.languages["full_translated"]["pt"]["en"]
70-
]
71-
7272
self.languages["full_translated"]["general"] = {}
7373

7474
for language in self.languages["small"]:
75-
self.languages["full_translated"]["general"][language] = self.texts["general, title()"][language]
75+
self.languages["full_translated"]["general"][language] = self.JSON.Language.texts["general, title()"][language]
7676

7777
self.languages["small"].insert(0, "general")
7878
self.languages["full"]["general"] = "General"
7979

8080
self.xampp_programs = [
8181
"xampp-control",
8282
"httpd",
83-
"mysql",
83+
"mysql"
8484
]
8585

8686
self.websites = {
8787
"list": self.JSON.To_Python(self.folders["mega"]["php"]["json"]["websites"]),
88-
"update": {},
88+
"update": {}
8989
}
9090

9191
for language in self.languages["small"]:
@@ -120,8 +120,7 @@ def Select_Website(self):
120120
self.Create_Websites_List()
121121

122122
if self.module_website != None:
123-
# If the module website is a string find the number of that website
124-
# If the module website is an integer, add it to the website numbers list
123+
# If the module website is a string or an integer, find the number of that website
125124
if type(self.module_website) in [str, int]:
126125
number = 0
127126
for website in self.websites["en"]:
@@ -207,7 +206,7 @@ def Create_Websites_List(self):
207206
def Open_And_Close_XAMPP(self, open = False, close = False):
208207
if open == True:
209208
if self.switches["testing"] == False:
210-
self.File.Open(self.root_folders["xampp"]["xampp-control"])
209+
self.File.Open(self.folders["root"]["xampp"]["xampp-control"])
211210

212211
self.Date.Sleep(4)
213212

@@ -269,15 +268,15 @@ def Update_Website(self, open = True, close = True):
269268
if self.switches["testing"] == False:
270269
self.File.Open(link)
271270

272-
self.Date.Sleep(5)
271+
self.Date.Sleep(4)
273272

274273
print()
275274
print(self.large_bar)
276275

277276
self.Input.Type(self.language_texts["press_enter_when_the_pages_finish_loading"])
278277

279278
def Open_Git_Console_Window(self):
280-
files = self.Folder.Contents(self.folders["apps"]["shortcuts"]["white_shortcuts"])["file"]["list"]
279+
files = self.Folder.Contents(self.folders["apps"]["shortcuts"]["root"])["file"]["list"]
281280

282281
for file in files:
283282
if "GitHub" in file:

Modules/Database/Database/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,6 @@ def Define_Registry_Format(self):
307307
if self.current_year["Number"] not in self.dictionaries["History"]["Years"]:
308308
self.dictionaries["History"]["Years"].append(self.current_year["Number"])
309309

310-
# Update the number of years with the length of the years list
311-
self.dictionaries["History"]["Numbers"]["Years"] = len(self.dictionaries["History"]["Years"])
312-
313310
entries = 0
314311

315312
# Update the number of entries of all years
@@ -332,6 +329,9 @@ def Define_Registry_Format(self):
332329
# Sort the Years list
333330
self.dictionaries["History"]["Years"] = sorted(self.dictionaries["History"]["Years"], key = str.lower)
334331

332+
# Update the number of years with the length of the years list
333+
self.dictionaries["History"]["Numbers"]["Years"] = len(self.dictionaries["History"]["Years"])
334+
335335
# Define the number of Entries of all years as the local number of entries
336336
self.dictionaries["History"]["Numbers"]["Entries"] = entries
337337

Modules/Diary_Slim/Create_New_Diary_Slim/__init__.py

+36-39
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ class Create_New_Diary_Slim(Diary_Slim):
1010
def __init__(self):
1111
super().__init__()
1212

13-
self.Define_Times()
14-
1513
print()
1614
print(self.large_bar)
1715
print()
@@ -40,14 +38,10 @@ def __init__(self):
4038
print()
4139
print(self.large_bar)
4240

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-
4841
def Make_Header(self):
4942
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)
5145

5246
self.select_text = self.language_texts["type_the_time_that_you_{}"].format(self.language_texts["have_gone_to_sleep"])
5347
self.sleeping_time = self.Match_Time_Pattern(self.select_text)
@@ -85,23 +79,23 @@ def Define_Slim_File(self):
8579
self.diary_slim_exists = False
8680

8781
# 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]
8983

90-
if self.File.Exist(self.current_day_file) == True:
84+
if self.File.Exist(self.current_year["File"]) == True:
9185
self.diary_slim_exists = True
9286

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"])
9589

9690
def Write_To_Files(self):
91+
from copy import deepcopy
92+
93+
# Write the header text
9794
if self.diary_slim_exists == False:
9895
print(self.dash_space)
9996
print()
10097

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"]
10599

106100
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
107101

@@ -111,38 +105,41 @@ def Write_To_Files(self):
111105
print()
112106
print(self.dash_space)
113107

114-
self.File.Open(self.current_day_file)
108+
# Open the Diary Slim file
109+
self.File.Open(self.current_year["File"])
115110

116111
# ----- #
117112

118113
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"])
123115

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+
}
126127

127-
self.File.Edit(self.month_folders_file, text_to_append, "a")
128+
# Edit the Month dictionary
129+
key = self.current_day
128130

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
131133

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()))
134136

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"])
139139

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"]
143142

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"])
147144

148-
# ----- #
145+
super().__init__()

Modules/Diary_Slim/Descriptions.json

+4
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
"Write_On_Diary_Slim": {
1111
"en": "Write on Diary Slim",
1212
"pt": "Escrever no Diário Slim"
13+
},
14+
"Manage": {
15+
"en": "Manage the [Diary Slim] Database and History",
16+
"pt": "Gerenciar o Banco de Dados e Histórico do [Diário Slim]"
1317
}
1418
}

0 commit comments

Comments
 (0)