From 8ed32b2fbe992b1214d44f484fe1a4c0abd47194 Mon Sep 17 00:00:00 2001 From: Het Patel <124852522+Hunterdii@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:45:08 +0530 Subject: [PATCH] Update update_commit.py --- src/update_commit.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/update_commit.py b/src/update_commit.py index ea64a09e..8925df04 100644 --- a/src/update_commit.py +++ b/src/update_commit.py @@ -15,29 +15,31 @@ # Get the current date today = datetime.today() - day_of_month = today.strftime("%d") # Get current day of the month - month = today.strftime("%B") # Get current full month name (e.g., November) - - # Format the solution file name for today (e.g., 06(Nov)Root to leaf paths sum.md) - today_solution_filename = f"{day_of_month}({today.strftime('%b')}){today.strftime('%A')}.md" + day_of_month = today.strftime("%d") # Get current day of the month (e.g., 06) + month = today.strftime("%b") # Get current month (e.g., Nov) + + # Prepare the solution filename for today (e.g., 06(Nov)Root to leaf paths sum.md) + # You can customize this to the exact naming pattern you use + today_solution_filename = f"{day_of_month}({month}){today.strftime('%A')}.md" # Prepare the badge URL and commit link to update README badge_url = "https://img.shields.io/badge/GeeksforGeeks-Solution%20of%20the%20Day-blue" - badge_link = f"[![Today's POTD Solution]({badge_url})](https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename})" + badge_link = f"[![Today's POTD Solution]({badge_url})](https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{day_of_month}({month}){today.strftime('%A')}.md)" # Read the README file and update the sections for commit and badge with open(readme_path, "r") as readme: content = readme.read() - # Update today's solution link in the README + # Update today's solution link (for the commit) + solution_url = f"https://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{day_of_month}({month}){today.strftime('%A')}.md" content = re.sub( r"(?<=).*?(?=)", - f"\nhttps://github.com/{repository}/blob/main/{month}%202024%20GFG%20SOLUTION/{today_solution_filename}\n", + f"\n{solution_url}\n", content, flags=re.DOTALL ) - # Update the badge link + # Update badge link content = re.sub( r"(?<=).*?(?=)", f"\n{badge_link}\n",