-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lua] Automate release and version retrieval
- Loading branch information
1 parent
172008c
commit 64e9d68
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |