mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-07 08:20:21 -05:00
refactor: replace manual total_seconds()/3600 with timedelta comparison
Use timedelta(hours=CACHE_MAX_AGE_HOURS) so the cache-age check reads at the intended hours unit directly, removing the conversion arithmetic. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
from collections.abc import Sequence
|
||||
from datetime import UTC, datetime
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from itertools import batched
|
||||
from pathlib import Path
|
||||
|
||||
@@ -119,13 +119,13 @@ def main() -> None:
|
||||
cache = pruned
|
||||
|
||||
# Determine which repos need fetching (missing or stale)
|
||||
max_age = timedelta(hours=CACHE_MAX_AGE_HOURS)
|
||||
to_fetch = []
|
||||
for repo in sorted(current_repos):
|
||||
entry = cache.get(repo)
|
||||
if entry and "fetched_at" in entry:
|
||||
fetched = datetime.fromisoformat(entry["fetched_at"])
|
||||
age_hours = (now - fetched).total_seconds() / 3600
|
||||
if age_hours < CACHE_MAX_AGE_HOURS:
|
||||
if now - fetched < max_age:
|
||||
continue
|
||||
to_fetch.append(repo)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user