Skip to content

Commit

Permalink
[libreoffice] Adds automation
Browse files Browse the repository at this point in the history
  • Loading branch information
captn3m0 authored and marcwrobel committed Jun 22, 2024
1 parent e888473 commit c6de8ca
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def parse_month_year_date(text: str, formats: list[str] = frozenset([
def parse_datetime(text: str, formats: list[str] = frozenset([
"%Y-%m-%d %H:%M:%S", # 2023-05-01 08:32:34
"%Y-%m-%dT%H:%M:%S", # 2023-05-01T08:32:34
"%d-%b-%Y %H:%M", # 01-May-2023 08:32
"%Y-%m-%d %H:%M:%S %z", # 2023-05-01 08:32:34 +0900
"%Y-%m-%dT%H:%M:%S%z", # 2023-05-01T08:32:34+0900
"%Y-%m-%dT%H:%M:%S.%f%z", # 2023-05-01T08:32:34.123456Z
Expand Down
29 changes: 29 additions & 0 deletions src/libreoffice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import re

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

"""Fetches Veeam versions from https://downloadarchive.documentfoundation.org/libreoffice/old/"""

VERSION_PATTERN = re.compile(r"^(?P<version>\d+(\.\d+)*)\/$")

with releasedata.ProductData("libreoffice") as product_data:
response = http.fetch_url("https://downloadarchive.documentfoundation.org/libreoffice/old/")
soup = BeautifulSoup(response.text, features="html5lib")

for table in soup.find_all("table"):

for row in table.find_all("tr")[1:]:
cells = row.find_all("td")

if len(cells) < 4:
continue

version_str = cells[1].get_text().strip() # x.y GA => x.y.0
date_str = cells[2].get_text().strip()
version_match = VERSION_PATTERN.match(version_str)

if version_match:
version = version_match["version"]
date = dates.parse_datetime(date_str)
product_data.declare_version(version, date)

0 comments on commit c6de8ca

Please sign in to comment.