Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import json
import os
import re
import shutil
import sys
from datetime import date, timedelta, datetime

MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]+$"

Expand All @@ -11,6 +14,20 @@
# exits with status 1 to indicate failure
sys.exit(1)

last_week = (datetime.now() - timedelta(days=7)).isoformat(timespec="seconds")
print(f"\nSetting dynamic variable 'one_week_calc' to last week: {last_week}\n")

try:
context_file = os.path.join(os.environ.get('COOKIECUTTER_CONTEXT_FILE', ''), 'cookiecutter.json')
if os.path.exists(context_file):
with open(context_file, "r") as f:
context = json.load(f)
context["one_week_calc"] = last_week
with open(context_file, "w") as f:
json.dump(context, f)
except Exception:
pass

# Check if UV is installed
if not shutil.which("uv"):
print("\n" + "=" * 80)
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.__package_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ warn_return_any = true
warn_unused_ignores = true

[tool.uv]
exclude-newer = "1 week"
exclude-newer = "{{ cookiecutter.one_week_calc | default('2026-03-13T00:00:00Z') }}"