|
15 | 15 |
|
16 | 16 | # Get the current date
|
17 | 17 | today = datetime.today()
|
18 |
| - day_of_month = today.strftime("%d") # Get current day of the month |
19 |
| - month = today.strftime("%B") # Get current full month name (e.g., November) |
20 |
| - |
21 |
| - # Format the solution file name for today (e.g., 06(Nov)Root to leaf paths sum.md) |
22 |
| - today_solution_filename = f"{day_of_month}({today.strftime('%b')}){today.strftime('%A')}.md" |
| 18 | + day_of_month = today.strftime("%d") # Get current day of the month (e.g., 06) |
| 19 | + month = today.strftime("%b") # Get current month (e.g., Nov) |
| 20 | + |
| 21 | + # Prepare the solution filename for today (e.g., 06(Nov)Root to leaf paths sum.md) |
| 22 | + # You can customize this to the exact naming pattern you use |
| 23 | + today_solution_filename = f"{day_of_month}({month}){today.strftime('%A')}.md" |
23 | 24 |
|
24 | 25 | # Prepare the badge URL and commit link to update README
|
25 | 26 | badge_url = "https://img.shields.io/badge/GeeksforGeeks-Solution%20of%20the%20Day-blue"
|
26 |
| - badge_link = f"[](https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename})" |
| 27 | + badge_link = f"[](https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{day_of_month}({month}){today.strftime('%A')}.md)" |
27 | 28 |
|
28 | 29 | # Read the README file and update the sections for commit and badge
|
29 | 30 | with open(readme_path, "r") as readme:
|
30 | 31 | content = readme.read()
|
31 | 32 |
|
32 |
| - # Update today's solution link in the README |
| 33 | + # Update today's solution link (for the commit) |
| 34 | + solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{day_of_month}({month}){today.strftime('%A')}.md" |
33 | 35 | content = re.sub(
|
34 | 36 | r"(?<=<!--START_SECTION:latest-commit-->).*?(?=<!--END_SECTION:latest-commit-->)",
|
35 |
| - f"\nhttps://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename}\n", |
| 37 | + f"\n{solution_url}\n", |
36 | 38 | content,
|
37 | 39 | flags=re.DOTALL
|
38 | 40 | )
|
39 | 41 |
|
40 |
| - # Update the badge link |
| 42 | + # Update badge link |
41 | 43 | content = re.sub(
|
42 | 44 | r"(?<=<!--START_SECTION:potd-badge-->).*?(?=<!--END_SECTION:potd-badge-->)",
|
43 | 45 | f"\n{badge_link}\n",
|
|
0 commit comments