Skip to content

Commit adea424

Browse files
committed
In the "Watch_History" module, I updated the "Create_Statistics" and "Update_Statistics" methods.
I updated them to separate watched media by media type. Now, each media type has its own dictionary to store its watched media. I added a dictionary with lists of media types in English and Portuguese, which will be used by the "Years" module in the creation of the yearly statistics files for each year. I also added a dictionary called "Translation dictionary" that will be used by the module mentioned above to translate media titles and their items I made various improvements to the statistics methods of the "Diary_Slim", "Stories", and "GamePlayer" classes.
1 parent 3c3b553 commit adea424

File tree

20 files changed

+2336
-673
lines changed

20 files changed

+2336
-673
lines changed

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": "2025-02-19 17:03:49-03:00",
13+
"Object": "2025-03-19 17:33:06-03:00",
1414
"Time": 0,
15-
"Time text": "17:03",
15+
"Time text": "17:33",
1616
"Unit": {
1717
"en": "hours",
1818
"pt": "horas"
@@ -23,9 +23,9 @@
2323
}
2424
},
2525
"Can drink water": {
26-
"Object": "2025-02-19 17:43:49-03:00",
26+
"Object": "2025-03-19 18:13:06-03:00",
2727
"Time": 40,
28-
"Time text": "17:43",
28+
"Time text": "18:13",
2929
"Unit": {
3030
"en": "minutes",
3131
"pt": "minutos"
@@ -36,9 +36,9 @@
3636
}
3737
},
3838
"Will be hungry": {
39-
"Object": "2025-02-19 20:03:49-03:00",
39+
"Object": "2025-03-19 20:33:06-03:00",
4040
"Time": 3,
41-
"Time text": "20:03",
41+
"Time text": "20:33",
4242
"Unit": {
4343
"en": "hours",
4444
"pt": "horas"

Module files/GamePlayer/Texts.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@
7575
"en": "First game session of the \"{}\" category in year",
7676
"pt": "Primeira sessão de jogo da categoria \"{}\" no ano"
7777
},
78-
"start_counting_the_session_time": {
79-
"en": "Start counting the session time",
80-
"pt": "Começar a contar o tempo de sessão"
78+
"start_counting_the_gaming_time": {
79+
"en": "Start counting the gaming time",
80+
"pt": "Começar a contar o tempo de jogatina"
8181
},
8282
"press_enter_when_you_finish_using_the_python_module_of_the_game": {
8383
"en": "Press Enter when you finish using the Python module of the game",

Module files/Watch_History/Texts.json

+15-3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
"en": "Last season",
7272
"pt": "Última temporada"
7373
},
74+
"comment_time": {
75+
"en": "Comment time",
76+
"pt": "Tempo do comentário"
77+
},
7478
"comment_file_name": {
7579
"en": "Comment file name",
7680
"pt": "Nome de arquivo de comentário"
@@ -79,6 +83,14 @@
7983
"en": "Loading already written comment",
8084
"pt": "Carregando comentário já escrito"
8185
},
86+
"and_its, masculine": {
87+
"en": "and its",
88+
"pt": "e o seu"
89+
},
90+
"and_its, feminine": {
91+
"en": "and its",
92+
"pt": "e a sua"
93+
},
8294
"watch": {
8395
"en": "watch",
8496
"pt": "assistir"
@@ -303,9 +315,9 @@
303315
"pt": "Digite o número de vezes que você assistiu",
304316
"en": "Type the number of times that you watched"
305317
},
306-
"times_that_i_watched_{}_{}": {
307-
"en": "Times that I watched {} \"{}\"",
308-
"pt": "Vezes que eu assisti {} \"{}\""
318+
"times_that_i_watched_{}": {
319+
"en": "Times that I watched {}",
320+
"pt": "Vezes que eu assisti {}"
309321
},
310322
"re_watched, capitalize()": {
311323
"pt": "Re-assistido",

Modules/Diary_Slim/Diary_Slim/__init__.py

+82-73
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def Define_History(self):
425425
# ---------- #
426426

427427
# Iterate through the years list
428+
# Years list: "2020" to the current year
428429
for year in self.years_list:
429430
# Create the year folder
430431
folders = {
@@ -1299,10 +1300,12 @@ def Create_External_Statistics(self):
12991300
# If the external statistics file is not empty
13001301
if self.File.Contents(file)["lines"] != []:
13011302
# Get the JSON dictionary
1302-
json_dictionary = self.JSON.To_Python(file)
1303+
#json_dictionary = self.JSON.To_Python(file)
13031304

13041305
# Update the root year dictionary with the local JSON one, using the "Define_Options" method
1305-
external_statistics = self.Define_Options(external_statistics, json_dictionary)
1306+
#external_statistics = self.Define_Options(external_statistics, json_dictionary)
1307+
1308+
test = ""
13061309

13071310
# ---------- #
13081311

@@ -1314,16 +1317,23 @@ def Create_External_Statistics(self):
13141317
**module
13151318
}
13161319

1320+
# Get the statistic key from the module dictionary
1321+
statistic_key = module["Statistic key"]
1322+
13171323
# Add the module title to the list of external statistics if it is not already present
13181324
if module_title not in external_statistics["List"]:
13191325
external_statistics["List"].append(module_title)
13201326

13211327
# Add the module title to the dictionary of external statistics if it is not already present
13221328
if module_title not in external_statistics["Dictionary"]:
1323-
external_statistics["Dictionary"][module_title] = {}
1324-
1325-
# Get the statistic key from the module dictionary
1326-
statistic_key = module["Statistic key"]
1329+
external_statistics["Dictionary"][module_title] = {
1330+
"Module": module_title,
1331+
"Statistic key": statistic_key,
1332+
"Text key": "",
1333+
"Text": {},
1334+
"List": [],
1335+
"Years": {}
1336+
}
13271337

13281338
# Add the statistic key to the list of keys if it is not already present
13291339
if statistic_key not in external_statistics["Keys"]:
@@ -1356,6 +1366,7 @@ def Create_External_Statistics(self):
13561366
if "Create_Statistics" in module["Methods"]:
13571367
# Get the dictionary of statistics from the "Create_Statistics" method
13581368
# Passing the list of years as a parameter
1369+
# Years list: "2020" to the current year
13591370
statistics = module["Class"].Create_Statistics(self.years_list)
13601371

13611372
# Define the dictionary of parameters
@@ -1562,6 +1573,8 @@ def Update_Statistics(self):
15621573

15631574
# Update the external statistics dictionaries of the years and months
15641575

1576+
update = False
1577+
15651578
# Iterate through the "External statistics" dictionary
15661579
for statistics in self.statistics["External statistics"]["Dictionary"].values():
15671580
# Define the statistic key
@@ -1591,16 +1604,16 @@ def Update_Statistics(self):
15911604
# Get the root statistics dictionary
15921605
root_statistics = root_year["Statistics"][statistic_key]
15931606

1594-
# Add the "Total" key and the number dictionaries inside the "Numbers" to the root year statistics dictionary
1595-
root_year["Statistics"][statistic_key] = {
1596-
"Module": root_statistics["Module"],
1597-
"Total": year["Total"],
1598-
"Dictionary": {
1599-
**year["Numbers"]
1607+
if update == True:
1608+
# Add the "Total" key and the number dictionaries inside the "Numbers" to the root year statistics dictionary
1609+
root_year["Statistics"][statistic_key] = {
1610+
"Module": root_statistics["Module"],
1611+
"Total": year["Total"],
1612+
"Dictionary": {
1613+
**year["Numbers"]
1614+
}
16001615
}
1601-
}
16021616

1603-
# Iterate through the months inside the year dictionary
16041617
for month in year["Months"].values():
16051618
# Get the month key using the list of month names in the user language with the month number with leading zeroes
16061619
month_key = month["Key"] + " - " + self.Date.language_texts["month_names, type: list"][int(month["Key"])]
@@ -1611,17 +1624,19 @@ def Update_Statistics(self):
16111624
# Get the root statistics dictionary
16121625
root_statistics = root_year["Months"][month_key]["Statistics"][statistic_key]
16131626

1614-
# Add the "Total" key and the number dictionaries inside the "Numbers" to the root month statistics dictionary
1615-
root_year["Months"][month_key]["Statistics"][statistic_key] = {
1616-
"Module": root_statistics["Module"],
1617-
"Total": month["Total"],
1618-
"Dictionary": {
1619-
**month["Numbers"]
1627+
if update == True:
1628+
# Add the "Total" key and the number dictionaries inside the "Numbers" to the root month statistics dictionary
1629+
root_year["Months"][month_key]["Statistics"][statistic_key] = {
1630+
"Module": root_statistics["Module"],
1631+
"Total": month["Total"],
1632+
"Dictionary": {
1633+
**month["Numbers"]
1634+
}
16201635
}
1621-
}
16221636

1623-
# Add the year dictionary to the local dictionary of years
1624-
years_dictionary[key] = root_year
1637+
if update == True:
1638+
# Add the year dictionary to the local dictionary of years
1639+
years_dictionary[key] = root_year
16251640

16261641
# Iterate through the dictionary of years
16271642
for key, year in self.years["Dictionary"].items():
@@ -1659,6 +1674,15 @@ def Update_Statistics(self):
16591674
# Remove the statistic from the "Statistics" dictionary
16601675
year["Months"][month_key]["Statistics"].pop(statistic_key)
16611676

1677+
# If the statistic key is not inside the month dictionary
1678+
if statistic_key not in month["Statistics"]:
1679+
# Add the "Total" key and the number dictionaries inside the "Numbers" to the root month statistics dictionary
1680+
year["Months"][month_key]["Statistics"][statistic_key] = {
1681+
"Module": statistic["Module"],
1682+
"Total": 0,
1683+
"Dictionary": {}
1684+
}
1685+
16621686
# Add the year dictionary to the local dictionary of years
16631687
years_dictionary[key] = year
16641688

@@ -1707,7 +1731,7 @@ def Update_External_Statistics(self, statistic_key, statistics):
17071731
parameters[0][statistic_key] = year_statistics
17081732

17091733
# Get the year statistics text
1710-
text += self.Show_Statistics("Year", year_statistics, statistics["Dictionary"], return_text = True) + "\n"
1734+
text += self.Show_Statistics("Year", statistics, return_text = True) + "\n"
17111735

17121736
# ---------- #
17131737

@@ -1718,7 +1742,7 @@ def Update_External_Statistics(self, statistic_key, statistics):
17181742
parameters[1][statistic_key] = month_statistics
17191743

17201744
# Get the year statistics text
1721-
text += self.Show_Statistics("Month", month_statistics, statistics["Dictionary"], return_text = True)
1745+
text += self.Show_Statistics("Month", statistics, return_text = True)
17221746

17231747
# ---------- #
17241748

@@ -1728,41 +1752,36 @@ def Update_External_Statistics(self, statistic_key, statistics):
17281752
# Return the statistics text
17291753
return text
17301754

1731-
def Show_Statistics(self, date_type, statistics, dictionary = None, return_text = False):
1755+
def Show_Statistics(self, date_type, statistics, return_text = False):
17321756
# Define the text key
17331757
text_key = date_type.lower()
17341758

1759+
# Define the new number as one
1760+
new_number = 1
1761+
17351762
# If the "Number" key is inside the statistics dictionary
17361763
if "Number" in statistics:
17371764
# Get the number of updated statistics for the month/year
17381765
new_number = statistics["Number"]
17391766

1740-
# If the "dictionary" parameter is not None
1741-
if dictionary != None:
1742-
# Get the old and new numbers from the numbers dictionary (inside the date type dictionary)
1743-
old_number = dictionary["Numbers"][date_type]["Old"]
1744-
new_number = 1
1745-
17461767
# Define the statistic text to show as singular or plural depending on the number
17471768
singular = self.Language.language_texts["updated_" + text_key + "_statistic"]
17481769
plural = self.Language.language_texts["updated_" + text_key + "_statistics"]
17491770

17501771
show_text = self.Text.By_Number(new_number, singular, plural)
17511772

1752-
# If the "dictionary" parameter is not None
1753-
if dictionary != None:
1754-
# Get the new number from the numbers dictionary (inside the date type dictionary)
1755-
new_number = dictionary["Numbers"][date_type]["New"]
1756-
17571773
# Define the root statistics text
17581774
statistics_text = "\n" + \
1759-
show_text + ":" + "\n"
1775+
show_text + ":"
17601776

17611777
# If the "return text" parameter is False
17621778
if return_text == False:
17631779
# Show the statistics text
17641780
print(statistics_text)
17651781

1782+
# Add a line break to the root statistics text
1783+
statistics_text += "\n"
1784+
17661785
# Define the default "in text" as "in [year]"
17671786
in_text = self.Language.language_texts["in"] + " " + str(self.diary_slim["Current year"]["Number"])
17681787

@@ -1771,58 +1790,48 @@ def Show_Statistics(self, date_type, statistics, dictionary = None, return_text
17711790
# Re-define the in text to be "in [month name]"
17721791
in_text = self.Language.language_texts["in"] + " " + str(self.diary_slim["Current year"]["Month"]["Name text"])
17731792

1774-
# If the "dictionary" parameter is not None
1775-
if dictionary != None:
1793+
# If the "External statistic" key is inside the statistics dictionary
1794+
if "External statistic" in statistics:
17761795
# Get the first key of the statistics dictionary
17771796
first_key = list(statistics["Dictionary"].keys())[0]
17781797

1779-
# Make a copy of the statistics dictionary
1798+
# Make a copy of the statistics dictionary to not modify the root one
17801799
statistics = deepcopy(statistics)
17811800

17821801
# Make the dictionary only have the first key
17831802
statistics["Dictionary"] = {
1784-
first_key: statistics["Dictionary"][first_key]
1803+
first_key: {
1804+
"Old number": statistics["Dictionary"]["Numbers"][date_type]["Old"],
1805+
"Number": statistics["Dictionary"]["Numbers"][date_type]["New"],
1806+
"Text": statistics["Text"]
1807+
}
17851808
}
17861809

17871810
# Iterate through the dictionary of statistics
17881811
for statistic in statistics["Dictionary"].values():
1789-
# If the statistic is a dictionary
1790-
if isinstance(statistic, dict):
1791-
# If the "Old number" key is inside the statistic dictionary
1792-
if "Old number" in statistic:
1793-
# Get the old number from it
1794-
old_number = statistic["Old number"]
1795-
1796-
# If the "Number" key is inside the statistic dictionary
1797-
if "Number" in statistic:
1798-
# Get the new number from it
1799-
new_number = statistic["Number"]
1800-
1801-
# If the "Text" key is inside the statistic dictionary
1802-
if "Text" in statistic:
1803-
text = statistic["Text"]
1804-
1805-
# If the "dictionary" parameter is not None
1806-
# And there is a "Text" key inside it
1807-
if (
1808-
dictionary != None and
1809-
"Text" in dictionary
1810-
):
1811-
# Get the text from it
1812-
text = dictionary["Text"]
1812+
# Get the old number
1813+
old_number = statistic["Old number"]
1814+
1815+
# Get the new number
1816+
new_number = statistic["Number"]
18131817

1814-
# Add the in text text and a colon
1818+
# If the "Text" key is inside the statistic dictionary
1819+
if "Text" in statistic:
1820+
# Define the text as it
1821+
text = statistic["Text"]
1822+
1823+
# Else, try to find it inside the root statistics dictionary
1824+
else:
1825+
text = statistics["Text"]
1826+
1827+
# Add the in text text and a colon and space
18151828
text = "\t" + text + " " + in_text + ": "
18161829

18171830
# Define the number
18181831
number = str(new_number)
18191832

1820-
# If the statistic is a dictionary
1821-
# And the "Money" key is inside the statistic dictionary
1822-
if (
1823-
isinstance(statistic, dict) and
1824-
"Money" in statistic
1825-
):
1833+
# If the "Money" key is inside the statistic dictionary
1834+
if "Money" in statistic:
18261835
# Define the money text
18271836
number = self.Define_Money_Text(number)
18281837

Modules/Diary_Slim/Write_On_Diary_Slim/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1212,8 +1212,10 @@ def Write(self):
12121212
# Show the statistics, passing the date type and the local dictionary as parameters
12131213
self.Show_Statistics(date_type, statistics)
12141214

1215-
# Open the current Diary Slim file
1216-
self.System.Open(self.diary_slim["Current year"]["Current Diary Slim file"], verbose = False)
1215+
# If the text to write is not empty
1216+
if self.dictionary["Text to write"] != "":
1217+
# Open the current Diary Slim file
1218+
self.System.Open(self.diary_slim["Current year"]["Current Diary Slim file"], verbose = False)
12171219

12181220
# Show a five dash space separator
12191221
print()

0 commit comments

Comments
 (0)