mirror of
https://github.com/vinta/awesome-python.git
synced 2026-08-04 15:05:39 +00: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:
parent
95115f7949
commit
6ae7c89688
1 changed files with 3 additions and 3 deletions
|
|
@ -6,7 +6,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime, timedelta
|
||||||
from itertools import batched
|
from itertools import batched
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -119,13 +119,13 @@ def main() -> None:
|
||||||
cache = pruned
|
cache = pruned
|
||||||
|
|
||||||
# Determine which repos need fetching (missing or stale)
|
# Determine which repos need fetching (missing or stale)
|
||||||
|
max_age = timedelta(hours=CACHE_MAX_AGE_HOURS)
|
||||||
to_fetch = []
|
to_fetch = []
|
||||||
for repo in sorted(current_repos):
|
for repo in sorted(current_repos):
|
||||||
entry = cache.get(repo)
|
entry = cache.get(repo)
|
||||||
if entry and "fetched_at" in entry:
|
if entry and "fetched_at" in entry:
|
||||||
fetched = datetime.fromisoformat(entry["fetched_at"])
|
fetched = datetime.fromisoformat(entry["fetched_at"])
|
||||||
age_hours = (now - fetched).total_seconds() / 3600
|
if now - fetched < max_age:
|
||||||
if age_hours < CACHE_MAX_AGE_HOURS:
|
|
||||||
continue
|
continue
|
||||||
to_fetch.append(repo)
|
to_fetch.append(repo)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue