Files
.profile/update_profile.py

34 lines
890 B
Python

import datetime
import os
import re
def generate_stats():
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return f"✅ My Gitea instance is alive and well!\n🕒 Last update: {now}."
def main():
readme_path = "README.MD"
if not os.path.exists(readme_path):
print(f"{readme_path} not found!")
return
with open(readme_path, "r", encoding="utf-8") as f:
content = f.read()
# Generate new dynamic content
stats_content = generate_stats()
# Replace content between the markers
pattern = r".*?"
replacement = f"\n{stats_content}\n"
new_content = re.sub(pattern, replacement, content, flags=re.DOTALL)
# 4. Save the file back to disk
with open(readme_path, "w", encoding="utf-8") as f:
f.write(new_content)
print("README.md updated locally.")
if __name__ == "__main__":
main()