|
15 | 15 | Disallowed_Characters = r'[\\/*?:"<>|]'
|
16 | 16 |
|
17 | 17 | if __name__ == "__main__":
|
18 |
| - # Part 1 - Validate Data |
| 18 | + # Part 1 - Validate Data |
19 | 19 |
|
20 |
| - # Read Credentials |
21 |
| - credentials_file = "\\".join([dirname(abspath(__file__)), "credentials.json"]) |
| 20 | + # Read Credentials |
| 21 | + credentials_file = "\\".join([dirname(abspath(__file__)), "credentials.json"]) |
22 | 22 |
|
23 |
| - # Verify Credentials file valid |
| 23 | + # Verify Credentials file valid |
24 | 24 |
|
25 |
| - # Parse Arguments |
26 |
| - args = parse_arguments(credentials_file) |
| 25 | + # Parse Arguments |
| 26 | + args = parse_arguments(credentials_file) |
27 | 27 |
|
28 |
| - # Validation |
| 28 | + # Validation |
29 | 29 |
|
30 |
| - # Step 1: Verify provided link is a valid URL |
31 |
| - if is_valid_url(args.link): |
32 |
| - # |
| 30 | + # Step 1: Verify provided link is a valid URL |
| 31 | + if is_valid_url(args.link): |
33 | 32 |
|
34 |
| - # Step 2 : Verify link domain is one of the permitted options. |
| 33 | + # Step 2 : Verify link domain is one of the permitted options. |
35 | 34 |
|
36 |
| - Platform = str((urlparse(args.link).netloc.split(".")[-2 :])[0]).capitalize() |
| 35 | + Platform = str((urlparse(args.link).netloc.split(".")[-2 :])[0]).capitalize() |
37 | 36 |
|
38 |
| - # Step 3 : Check Valid Username |
| 37 | + # Step 3 : Check Valid Username |
39 | 38 |
|
40 |
| - # Step 4 : Check Template.md file exists. |
| 39 | + # Step 4 : Check Template.md file exists. |
41 | 40 |
|
42 |
| - # Step 5: Check Template.md file contains appropriate ids. |
| 41 | + # Step 5: Check Template.md file contains appropriate ids. |
43 | 42 |
|
44 |
| - # Part 2 - Request Info |
| 43 | + # Part 2 - Request Info |
45 | 44 |
|
46 |
| - # Given the URL extract the Challenge ID |
47 |
| - ID = extract_id(args.link) |
| 45 | + # Given the URL extract the Challenge ID |
| 46 | + ID = extract_id(args.link) |
48 | 47 |
|
49 |
| - # Make API call and Fetch Response |
50 |
| - response_json = fetch("{}{}".format(args.link, ID)) |
| 48 | + # Make API call and Fetch Response |
| 49 | + response_json = fetch("{}{}".format(args.link, ID)) |
51 | 50 |
|
52 |
| - # Determine info based on Request Response |
53 |
| - Challenge_Name = re.sub(Disallowed_Characters, "", response_json["name"]) |
54 |
| - Challenge_URL = str("\\".join([response_json["url"], "python"])).strip() |
55 |
| - Challenge_Rank = str(re.sub(" ", "-", response_json["rank"]["name"])).strip() |
56 |
| - Challenge_Tags = ", ".join(response_json["tags"]).strip() |
| 51 | + # Determine info based on Request Response |
| 52 | + Challenge_Name = re.sub(Disallowed_Characters, "", response_json["name"]) |
| 53 | + Challenge_URL = str("\\".join([response_json["url"], "python"])).strip() |
| 54 | + Challenge_Rank = str(re.sub(" ", "-", response_json["rank"]["name"])).strip() |
| 55 | + Challenge_Tags = ", ".join(response_json["tags"]).strip() |
57 | 56 |
|
58 |
| - # Call update.py |
| 57 | + # Call update.py |
59 | 58 |
|
60 |
| - # Fetch response in the form of database.json |
| 59 | + # Fetch response in the form of database.json |
61 | 60 |
|
62 |
| - # Validate |
| 61 | + # Validate |
63 | 62 |
|
64 |
| - # Parse JSON |
| 63 | + # Parse JSON |
65 | 64 |
|
66 |
| - # Fetch Completion Date |
| 65 | + # Fetch Completion Date |
67 | 66 |
|
68 |
| - # Part 3 - Update Structure |
| 67 | + # Part 3 - Update Structure |
69 | 68 |
|
70 |
| - # Determine New Challenge file path |
71 |
| - path = "\\".join([dirname(abspath(__file__)), Platform, Challenge_Rank, Challenge_Name]) |
| 69 | + # Determine New Challenge file path |
| 70 | + path = "\\".join([dirname(abspath(__file__)), Platform, Challenge_Rank, Challenge_Name]) |
72 | 71 |
|
73 |
| - # Determine template path based on argument or keep default value. |
74 |
| - Template_Path = "\\".join([dirname(abspath(__file__)), "Template.md"]) |
| 72 | + # Determine template path based on argument or keep default value. |
| 73 | + Template_Path = "\\".join([dirname(abspath(__file__)), "Template.md"]) |
75 | 74 |
|
76 |
| - # Create a folder for this new challenge based on path. |
77 |
| - create_folder(path) |
| 75 | + # Create a folder for this new challenge based on path. |
| 76 | + create_folder(path) |
78 | 77 |
|
79 |
| - # Initiate the Folder Structure |
80 |
| - initiate_structure(path) |
| 78 | + # Initiate the Folder Structure |
| 79 | + initiate_structure(path) |
81 | 80 |
|
82 |
| - # Model README.md based on Template |
83 |
| - edit_template( |
84 |
| - challenge_name = Challenge_Name, |
85 |
| - challenge_url = Challenge_URL, |
86 |
| - completion_date = "Wednesday, 30 December 2024", |
87 |
| - tags = Challenge_Tags, |
88 |
| - template_path = Template_Path, |
89 |
| - readme_file = "\\".join([path, "README.md"]), |
90 |
| - ) |
| 81 | + # Model README.md based on Template |
| 82 | + edit_template( |
| 83 | + challenge_name = Challenge_Name, |
| 84 | + challenge_url = Challenge_URL, |
| 85 | + completion_date = "Wednesday, 30 December 2024", |
| 86 | + tags = Challenge_Tags, |
| 87 | + template_path = Template_Path, |
| 88 | + readme_file = "\\".join([path, "README.md"]), |
| 89 | + ) |
91 | 90 |
|
92 |
| - # Part 4 - Results |
| 91 | + # Part 4 - Results |
93 | 92 |
|
94 |
| - # Ask user for their solution? |
| 93 | + # Ask user for their solution? |
95 | 94 |
|
96 |
| - # Open Folder? |
| 95 | + # Open Folder? |
97 | 96 |
|
98 |
| - # open_file |
| 97 | + # open_file |
0 commit comments