|
1 |
| -# Create_Friend_Folder.py |
| 1 | +# Add_A_New_Friend.py |
2 | 2 |
|
3 | 3 | from Friends.Friends import Friends as Friends
|
4 | 4 |
|
5 | 5 | from copy import deepcopy
|
6 | 6 | import collections
|
7 | 7 |
|
8 |
| -class Create_Friend_Folder(Friends): |
| 8 | +class Add_A_New_Friend(Friends): |
9 | 9 | def __init__(self):
|
10 | 10 | super().__init__()
|
11 | 11 |
|
@@ -33,7 +33,7 @@ def __init__(self):
|
33 | 33 |
|
34 | 34 | self.Select_Friend()
|
35 | 35 |
|
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 |
37 | 37 | if self.dictionary["States"]["Add Social Network to existing friend folder"] == False:
|
38 | 38 | self.Type_Friend_Information()
|
39 | 39 |
|
@@ -264,8 +264,8 @@ def Add_Social_Network(self):
|
264 | 264 |
|
265 | 265 | # If the Social Network is not inside the list of Social Networks of the Friend
|
266 | 266 | 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) |
269 | 269 |
|
270 | 270 | # Add the Social Network to the Social Networks list
|
271 | 271 | self.friend["Social Networks"]["List"].append(self.social_network["Name"])
|
@@ -308,13 +308,12 @@ def Define_Friend_Folders_And_Files(self):
|
308 | 308 | if self.friend["Name"] not in self.friends["List"]:
|
309 | 309 | self.friends["List"].append(self.friend["Name"])
|
310 | 310 |
|
311 |
| - # Define and create the friend folder type dictionaries |
| 311 | + # Define and create the friend folders and files |
312 | 312 | for item in ["Text", "Image"]:
|
313 | 313 | # Define the item key inside the "Files" dictionary
|
314 | 314 | self.friend["Files"][item] = {}
|
315 | 315 |
|
316 |
| - # Define and create the friend folders and files |
317 |
| - for item in ["Text", "Image"]: |
| 316 | + # Define the root folder |
318 | 317 | folder = self.folders["Friends"][item]["root"] + self.friend["Name"] + "/"
|
319 | 318 |
|
320 | 319 | # Create the folders dictionary
|
@@ -379,20 +378,31 @@ def Define_Friend_Folders_And_Files(self):
|
379 | 378 |
|
380 | 379 | # ---------- #
|
381 | 380 |
|
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 |
384 | 390 | files = {}
|
385 | 391 |
|
386 | 392 | # Iterate through the folder type list
|
387 | 393 | for item in ["Text", "Image"]:
|
| 394 | + # Get the file of the folder type with the file name |
388 | 395 | file = self.friend["Files"][item][file_name]
|
389 | 396 |
|
| 397 | + # Define the file dictionary with the file and file size |
390 | 398 | files[item] = {
|
391 | 399 | "File": file,
|
392 | 400 | "Size": self.File.Contents(file)["size"]
|
393 | 401 | }
|
394 | 402 |
|
| 403 | + # If the size of the file on the text folder is different than the file of the image folder |
395 | 404 | 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 |
396 | 406 | self.File.Copy(files["Text"]["File"], files["Image"]["File"])
|
397 | 407 |
|
398 | 408 | # ---------- #
|
@@ -453,6 +463,8 @@ def Define_Friend_Folders_And_Files(self):
|
453 | 463 |
|
454 | 464 | self.Folder.Create(folder)
|
455 | 465 |
|
| 466 | + # ---------- # |
| 467 | + |
456 | 468 | # Update the number of Social Networks
|
457 | 469 | self.friend["Social Networks"]["Numbers"]["Total"] = len(self.friend["Social Networks"]["List"])
|
458 | 470 |
|
@@ -550,7 +562,7 @@ def Write_To_Files(self):
|
550 | 562 | self.JSON.Edit(self.folders["Friends"]["Text"]["Friends"], local_dictionary)
|
551 | 563 |
|
552 | 564 | def Show_Information(self):
|
553 |
| - # Show a separator |
| 565 | + # Show a five dash space separator |
554 | 566 | print()
|
555 | 567 | print(self.separators["5"])
|
556 | 568 | print()
|
@@ -630,7 +642,7 @@ def Show_Information(self):
|
630 | 642 | print()
|
631 | 643 | print(text_to_show + ":")
|
632 | 644 |
|
633 |
| - # Iterate through the Social Networks list |
| 645 | + # Define the two tabs variable |
634 | 646 | two_tabs = "\t\t"
|
635 | 647 |
|
636 | 648 | # Iterate through the Social Networks list
|
@@ -664,9 +676,11 @@ def Show_Information(self):
|
664 | 676 | # Show the language information item and the current information
|
665 | 677 | print(two_tabs + language_information_item + ":")
|
666 | 678 |
|
| 679 | + # Define the current information as the "Empty" text if it is empty |
667 | 680 | if current_information == "":
|
668 | 681 | current_information = self.Language.language_texts["empty, title()"]
|
669 | 682 |
|
| 683 | + # Show the current information with two tabs |
670 | 684 | print(two_tabs + current_information)
|
671 | 685 |
|
672 | 686 | # Show a final separator
|
|
0 commit comments