Skip to content

Commit

Permalink
[lua] Automate release and version retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
marcwrobel committed Aug 15, 2024
1 parent 172008c commit 64e9d68
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lua.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import re

from bs4 import BeautifulSoup
from common import dates, http, releasedata

"""Fetches Lua releases from lua.org."""

RELEASED_AT_PATTERN = re.compile(r"Lua\s*(?P<release>\d+\.\d+)\s*was\s*released\s*on\s*(?P<release_date>\d+\s*\w+\s*\d{4})")
VERSION_PATTERN = re.compile(r"(?P<version>\d+\.\d+\.\d+),\s*released\s*on\s*(?P<version_date>\d+\s*\w+\s*\d{4})")

with releasedata.ProductData("lua") as product_data:
page = http.fetch_url("https://www.lua.org/versions.html")
soup = BeautifulSoup(page.text, 'html.parser')
page_text = soup.text # HTML is broken, no way to parse it with beautifulsoup

for release_match in RELEASED_AT_PATTERN.finditer(page_text):
release = release_match.group('release')
release_date = dates.parse_date(release_match.group('release_date'))
product_data.get_release(release).set_release_date(release_date)

for version_match in VERSION_PATTERN.finditer(page_text):
version = version_match.group('version')
version_date = dates.parse_date(version_match.group('version_date'))
product_data.declare_version(version, version_date)

0 comments on commit 64e9d68

Please sign in to comment.