Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: future proof upload_time parsing (try to parse only the date as a fallback solution) #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions remove_old_wheels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Remove all but the latest N versions from wheels on Anaconda.org
import re
from datetime import datetime, timezone, timedelta

import click
Expand All @@ -14,6 +15,10 @@ def _parse_upload_time(upload_time: str) -> datetime:
return datetime.strptime(upload_time, fmt)
except ValueError:
continue
if (match := re.match(r"\d{4}-\d{2}-\d{2}", upload_time)) is not None:
# fallback solution: renounce everything but the date if it can be saved
return datetime.strftime(match.group())

raise ValueError(
f"Failed to parse upload time {upload_time!r} "
"(didn't match any known format)"
Expand Down
Loading