Skip to content

Commit

Permalink
sort packages
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Sep 5, 2023
1 parent 48fb910 commit e6cb0d3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/check_latest_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@
def main(*packages):
allowed_date = date.today() - timedelta(days=2)
is_latest = True
for package in packages:
for package in sorted(packages):
url = f"https://pypi.org/pypi/{package}/json"
resp = requests.get(url).json()
latest = resp["info"]["version"]
current = __import__(package).__version__

latest_release_date = datetime.fromisoformat(
resp["releases"][latest][0]["upload_time_iso_8601"]
).date()
current_release_date = datetime.fromisoformat(
resp["releases"][current][0]["upload_time_iso_8601"]
).date()

version_check = Version(current) >= Version(latest)
date_check = allowed_date >= latest_release_date
is_latest &= version_check and date_check

print(
f"Package: {package:<10} Current: {current:<7} ({current_release_date})\tLatest: {latest:<7} ({latest_release_date})"
)
Expand Down

0 comments on commit e6cb0d3

Please sign in to comment.