From 64e9d682150e2f12e52b2193759f2e4c54b98460 Mon Sep 17 00:00:00 2001 From: Marc Wrobel Date: Thu, 15 Aug 2024 14:22:32 +0200 Subject: [PATCH] [lua] Automate release and version retrieval --- src/lua.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/lua.py diff --git a/src/lua.py b/src/lua.py new file mode 100644 index 000000000..3c87efdeb --- /dev/null +++ b/src/lua.py @@ -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\d+\.\d+)\s*was\s*released\s*on\s*(?P\d+\s*\w+\s*\d{4})") +VERSION_PATTERN = re.compile(r"(?P\d+\.\d+\.\d+),\s*released\s*on\s*(?P\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)