Skip to content

Commit 7c8d473

Browse files
committed
In the "Social_Networks" module I started to create the "Add_Social_Network" sub-class.
I did the main methods, to enter the social network information and add the information itens. And also add the social network profile, define folders and files, write to them, and show the information.
1 parent 4bd1391 commit 7c8d473

File tree

22 files changed

+1376
-300
lines changed

22 files changed

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

Module files/Friends/Texts.json

-8
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@
4141
"pt": "Pesquisar por um arquivo de {} de amigo",
4242
"en": "Search for a friend {} file"
4343
},
44-
"select_the_information_item": {
45-
"pt": "Selecione o item de informação",
46-
"en": "Select the information item"
47-
},
48-
"select_one_information_item": {
49-
"pt": "Selecione um item de informação",
50-
"en": "Select a information item"
51-
},
5244
"type_{}": {
5345
"pt": "Digite {}",
5446
"en": "Type {}"

Module files/Social_Networks/Texts.json

+29-1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,33 @@
4949
},
5050
"settings, type: list": [
5151
"create_image_folders"
52-
]
52+
],
53+
"please_type_the_information_of_the_social_network": {
54+
"pt": "Por favor digite as informações da rede social",
55+
"en": "Please type the information of the social network"
56+
},
57+
"please_type_the_information_of_your_profile_in_this_social_network": {
58+
"pt": "Por favor digite as informações do seu perfil nesta rede social",
59+
"en": "Please type the information of your profile in this social network"
60+
},
61+
"you_added_this_social_network_to_the_social_networks_database": {
62+
"pt": "Você adicionou esta rede social ao banco de dados de Redes Sociais",
63+
"en": "You added this social network to the Social Networks database"
64+
},
65+
"use_pre_existing_information_items": {
66+
"pt": "Usar itens de informação pré-existentes",
67+
"en": "Use pre-existing information items"
68+
},
69+
"create_new_information_items": {
70+
"pt": "Criar novos itens de informação",
71+
"en": "Create new information items"
72+
},
73+
"does_the_information_item_has_a_format": {
74+
"pt": "Does the information item has a format",
75+
"en": "O item de informação tem um formato"
76+
},
77+
"does_the_information_item_has_additional_items": {
78+
"pt": "Does the information item has additional items",
79+
"en": "O item de informação tem itens adicionais"
80+
}
5381
}

Module files/Stories/Texts.json

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
"en": "Select a story to",
2828
"pt": "Selecione uma história para"
2929
},
30+
"chapter_selection": {
31+
"en": "chapter selection",
32+
"pt": "seleção de capítulo"
33+
},
3034
"cover_creation": {
3135
"en": "cover creation",
3236
"pt": "criação de capa"
@@ -285,6 +289,10 @@
285289
"en": "post",
286290
"pt": "postar"
287291
},
292+
"select_chapter": {
293+
"en": "Select a chapter",
294+
"pt": "Selecionar um capítulo"
295+
},
288296
"select_{}_to_{}": {
289297
"en": "Select {} to {}",
290298
"pt": "Selecione {} para {}"

Module files/Tasks/Texts.json

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
"en": "This task was registered",
4040
"pt": "Esta tarefa foi registrada"
4141
},
42-
"show_task_description": {
43-
"en": "Show task description",
44-
"pt": "Mostrar descrição da tarefa"
45-
},
4642
"select_a_task_type": {
4743
"en": "Select a task type",
4844
"pt": "Selecione um tipo de tarefa"
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"Testing": false,
3-
"Verbose": false,
2+
"Testing": true,
3+
"Verbose": true,
44
"User information": false,
55
"Has active switches": false
66
}

Module files/Utility/Language/Texts.json

+8
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,14 @@
777777
"en": "Information items",
778778
"pt": "Itens de informação"
779779
},
780+
"select_the_information_item": {
781+
"pt": "Selecione o item de informação",
782+
"en": "Select the information item"
783+
},
784+
"select_one_information_item": {
785+
"pt": "Selecione um item de informação",
786+
"en": "Select a information item"
787+
},
780788
"name, title()": {
781789
"en": "Name",
782790
"pt": "Nome"

Modules/Friends/Create_Friend_Folder/__init__.py renamed to Modules/Friends/Add_A_New_Friend/__init__.py

+26-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Create_Friend_Folder.py
1+
# Add_A_New_Friend.py
22

33
from Friends.Friends import Friends as Friends
44

55
from copy import deepcopy
66
import collections
77

8-
class Create_Friend_Folder(Friends):
8+
class Add_A_New_Friend(Friends):
99
def __init__(self):
1010
super().__init__()
1111

@@ -33,7 +33,7 @@ def __init__(self):
3333

3434
self.Select_Friend()
3535

36-
# If not, type the information of the new Friend to be added
36+
# If not, ask the user to type the information of the new Friend to be added
3737
if self.dictionary["States"]["Add Social Network to existing friend folder"] == False:
3838
self.Type_Friend_Information()
3939

@@ -264,8 +264,8 @@ def Add_Social_Network(self):
264264

265265
# If the Social Network is not inside the list of Social Networks of the Friend
266266
if self.social_network["Name"] not in self.friend["Social Networks"]["List"]:
267-
# Asks for the user to type information about the selected Social Network
268-
self.social_network = self.Social_Networks.Type_Social_Network_Information(first_separator = first_separator)
267+
# Asks for the user to type information about the selected Social Network profile
268+
self.social_network = self.Social_Networks.Type_Social_Network_Information(social_network = self.social_network, first_separator = first_separator)
269269

270270
# Add the Social Network to the Social Networks list
271271
self.friend["Social Networks"]["List"].append(self.social_network["Name"])
@@ -308,13 +308,12 @@ def Define_Friend_Folders_And_Files(self):
308308
if self.friend["Name"] not in self.friends["List"]:
309309
self.friends["List"].append(self.friend["Name"])
310310

311-
# Define and create the friend folder type dictionaries
311+
# Define and create the friend folders and files
312312
for item in ["Text", "Image"]:
313313
# Define the item key inside the "Files" dictionary
314314
self.friend["Files"][item] = {}
315315

316-
# Define and create the friend folders and files
317-
for item in ["Text", "Image"]:
316+
# Define the root folder
318317
folder = self.folders["Friends"][item]["root"] + self.friend["Name"] + "/"
319318

320319
# Create the folders dictionary
@@ -379,20 +378,31 @@ def Define_Friend_Folders_And_Files(self):
379378

380379
# ---------- #
381380

382-
# Update the "Information" and "Social Networks" files of the Friend image folder if the file inside the text folder is different
383-
for file_name in ["Information", "Social Networks"]:
381+
# Define the list of file names
382+
file_names = [
383+
"Information",
384+
"Social Networks"
385+
]
386+
387+
# Update the friend files of the image folder if the file inside the text folder is different
388+
for file_name in file_names:
389+
# Define the empty files dictionary
384390
files = {}
385391

386392
# Iterate through the folder type list
387393
for item in ["Text", "Image"]:
394+
# Get the file of the folder type with the file name
388395
file = self.friend["Files"][item][file_name]
389396

397+
# Define the file dictionary with the file and file size
390398
files[item] = {
391399
"File": file,
392400
"Size": self.File.Contents(file)["size"]
393401
}
394402

403+
# If the size of the file on the text folder is different than the file of the image folder
395404
if files["Text"]["Size"] != files["Image"]["Size"]:
405+
# Replace the file on the image folder with the one on the text folder, updating the file
396406
self.File.Copy(files["Text"]["File"], files["Image"]["File"])
397407

398408
# ---------- #
@@ -453,6 +463,8 @@ def Define_Friend_Folders_And_Files(self):
453463

454464
self.Folder.Create(folder)
455465

466+
# ---------- #
467+
456468
# Update the number of Social Networks
457469
self.friend["Social Networks"]["Numbers"]["Total"] = len(self.friend["Social Networks"]["List"])
458470

@@ -550,7 +562,7 @@ def Write_To_Files(self):
550562
self.JSON.Edit(self.folders["Friends"]["Text"]["Friends"], local_dictionary)
551563

552564
def Show_Information(self):
553-
# Show a separator
565+
# Show a five dash space separator
554566
print()
555567
print(self.separators["5"])
556568
print()
@@ -630,7 +642,7 @@ def Show_Information(self):
630642
print()
631643
print(text_to_show + ":")
632644

633-
# Iterate through the Social Networks list
645+
# Define the two tabs variable
634646
two_tabs = "\t\t"
635647

636648
# Iterate through the Social Networks list
@@ -664,9 +676,11 @@ def Show_Information(self):
664676
# Show the language information item and the current information
665677
print(two_tabs + language_information_item + ":")
666678

679+
# Define the current information as the "Empty" text if it is empty
667680
if current_information == "":
668681
current_information = self.Language.language_texts["empty, title()"]
669682

683+
# Show the current information with two tabs
670684
print(two_tabs + current_information)
671685

672686
# Show a final separator

Modules/Friends/Descriptions.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"en": "Open Friend file",
88
"pt": "Abrir arquivo de Amigo"
99
},
10-
"Create_Friend_Folder": {
11-
"en": "Create friend folder",
12-
"pt": "Criar pasta de Amigo"
10+
"Add_A_New_Friend": {
11+
"en": "Add a new friend",
12+
"pt": "Adicionar um novo amigo"
1313
},
1414
"Show_Friend_Information": {
1515
"en": "Show information of all Friends",

Modules/Friends/Friends/__init__.py

+34-6
Original file line numberDiff line numberDiff line change
@@ -684,19 +684,31 @@ def Define_Friends_Dictionary(self):
684684

685685
# ---------- #
686686

687-
# Update the "Information" and "Social Networks" files of the Friend image folder if the file inside the text folder is different
688-
for file_name in ["Information", "Social Networks"]:
687+
# Define the list of file names
688+
file_names = [
689+
"Information",
690+
"Social Networks"
691+
]
692+
693+
# Update the friend files of the image folder if the file inside the text folder is different
694+
for file_name in file_names:
695+
# Define the empty files dictionary
689696
files = {}
690697

698+
# Iterate through the folder type list
691699
for item in ["Text", "Image"]:
700+
# Get the file of the folder type with the file name
692701
file = dictionary["Files"][item][file_name]
693702

703+
# Define the file dictionary with the file and file size
694704
files[item] = {
695705
"File": file,
696706
"Size": self.File.Contents(file)["size"]
697707
}
698708

709+
# If the size of the file on the text folder is different than the file of the image folder
699710
if files["Text"]["Size"] != files["Image"]["Size"]:
711+
# Replace the file on the image folder with the one on the text folder, updating the file
700712
self.File.Copy(files["Text"]["File"], files["Image"]["File"])
701713

702714
# ---------- #
@@ -909,31 +921,46 @@ def Define_Friends_Dictionary(self):
909921
self.JSON.Edit(self.folders["Friends"]["Text"]["Friends"], local_dictionary)
910922

911923
def Information(self, information = None, file = None, information_items = None, to_user_language = False):
924+
# If the file parameter is not None
912925
if file != None:
926+
# Get the information from it
913927
information = self.File.Dictionary(file, next_line = True)
914928

929+
# If the information items parameter is None, define it as the default root information items dictionary
915930
if information_items == None:
916931
information_items = self.information_items
917932

933+
# Define the empty dictionary
918934
dictionary = {}
919935

936+
# Iterate through the language keys and values of the information dictionary
920937
for information_key, value in information.items():
921-
correct_key = ""
938+
# Define the correct (original) key
939+
correct_key = information_key
922940

923-
for key, information_item in information_items["Dictionary"].items():
941+
# Iterate through the English keys and values of the root default information items dictionary
942+
for key, information_item in self.information_items["Dictionary"].items():
943+
# Get the language key of the information item
924944
language_key = information_item[self.user_language]
925945

946+
# If the local current (English) key is the same as the root (user language) key
947+
# Or the root (user language) key is the same as the language key
926948
if (
927949
key == information_key or
928-
information_key == information_item[self.user_language]
950+
information_key == language_key
929951
):
952+
# Define the correct key as the current English key
930953
correct_key = key
931954

955+
# If the "to user language" parameter is True
932956
if to_user_language == True:
957+
# Define the key as the user language key
933958
correct_key = language_key
934959

960+
# Add the information to the dictionary with the correct and selected key, be it English or user language
935961
dictionary[correct_key] = value
936962

963+
# Return the information dictionary with the updated keys
937964
return dictionary
938965

939966
def Select_File_Name(self):
@@ -971,6 +998,7 @@ def Select_Information_Item(self, information_items = None, information_item = N
971998
for item in information_items["Lists"]["Remove from search"]:
972999
options.remove(item)
9731000

1001+
# Define the language options
9741002
language_options = []
9751003

9761004
for option in options:
@@ -986,7 +1014,7 @@ def Select_Information_Item(self, information_items = None, information_item = N
9861014

9871015
# Define the show and select text
9881016
show_text = self.Language.language_texts["information_items"]
989-
select_text = self.language_texts["select_the_information_item"]
1017+
select_text = self.Language.language_texts["select_the_information_item"]
9901018

9911019
# If the "information_item" parameter is None
9921020
if information_item == None:

0 commit comments

Comments
 (0)