|
18 | 18 | day_of_month = today.strftime("%d") # Get current day of the month (e.g., 06)
|
19 | 19 | month = today.strftime("%b") # Get current month (e.g., Nov)
|
20 | 20 |
|
21 |
| - # Generate the filename based on the day of the month (e.g., 06(Nov) Root to leaf paths sum.md) |
22 |
| - today_solution_filename = f"{day_of_month}({month})" # The pattern that matches the filename format. |
| 21 | + # Prepare the solution filename for today (e.g., 06(Nov) Root to leaf paths sum.md) |
| 22 | + today_solution_filename = f"{day_of_month}({month}) Root to leaf paths sum.md" |
23 | 23 |
|
24 | 24 | # Make a request to GitHub to list files in the directory
|
25 | 25 | dir_url = f"https://api.github.com/repos/{repository}/contents/{month}%202024%20GFG%20SOLUTION"
|
|
31 | 31 |
|
32 | 32 | files = response.json()
|
33 | 33 |
|
34 |
| - # Check if files are empty or response is not valid |
35 |
| - if isinstance(files, dict) and files.get('message') == 'Not Found': |
| 34 | + # Check if the directory exists or if there are any issues |
| 35 | + if isinstance(files, dict) and 'message' in files and files['message'] == 'Not Found': |
36 | 36 | print(f"Directory not found: {dir_url}")
|
37 | 37 | sys.exit(1)
|
38 | 38 |
|
39 |
| - # Search for the correct file based on the date |
| 39 | + # Now, we try to find the solution file for today |
40 | 40 | today_file = None
|
41 | 41 | for file in files:
|
42 |
| - if file['name'].startswith(today_solution_filename): |
| 42 | + if file['name'].startswith(f"{day_of_month}({month})"): |
43 | 43 | today_file = file['name']
|
44 | 44 | break
|
45 | 45 |
|
46 | 46 | if not today_file:
|
47 |
| - print(f"No solution file found for {today_solution_filename}. Please check the directory.") |
| 47 | + print(f"Solution file for {today_solution_filename} not found.") |
48 | 48 | sys.exit(1)
|
49 | 49 |
|
50 |
| - # Prepare the correct file URL based on the found filename |
51 |
| - solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_file}" |
52 |
| - |
53 | 50 | # Prepare the badge URL with the correct link to today's solution
|
| 51 | + solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_file}" |
54 | 52 | badge_url = "https://img.shields.io/badge/GeeksforGeeks-Solution%20of%20the%20Day-blue"
|
55 | 53 | badge_link = f"[]({solution_url})"
|
56 | 54 |
|
|
0 commit comments