From: "Matt Jolly" <kangie@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/chromium-tools:master commit in: /
Date: Wed, 20 Mar 2024 21:45:19 +0000 (UTC) [thread overview]
Message-ID: <1710971104.8e0913a8a053444ee7f68cabb2075c5efbd1e246.kangie@gentoo> (raw)
commit: 8e0913a8a053444ee7f68cabb2075c5efbd1e246
Author: Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 20 21:45:04 2024 +0000
Commit: Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Wed Mar 20 21:45:04 2024 +0000
URL: https://gitweb.gentoo.org/proj/chromium-tools.git/commit/?id=8e0913a8
new script: get-opera-version-mapping
Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>
get-opera-version-mapping.py | 115 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/get-opera-version-mapping.py b/get-opera-version-mapping.py
new file mode 100755
index 0000000..43f8f32
--- /dev/null
+++ b/get-opera-version-mapping.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+import requests
+from bs4 import BeautifulSoup
+
+
+def get_opera_chromium_versions(base_url, start_version, end_version):
+ """
+ Extracts Opera and Chromium versions from the given base URL with version placeholders,
+ parsing content sections for versions from start_version to end_version (inclusive).
+
+ Args:
+ base_url: The base URL for Opera changelogs with a version placeholder (e.g., "https://blogs.opera.com/desktop/changelog-for-{version}/").
+ start_version: The starting version to extract information for (inclusive).
+ end_version: The ending version to extract information for (inclusive).
+
+ Returns:
+ A dictionary mapping Opera version to Chromium version.
+ If no update is mentioned, the previous Chromium version is used.
+ For missing data or errors, "unknown" is used.
+ """
+ versions = {}
+ chromium_version = None
+
+ for version in range(start_version, end_version + 1):
+ # Fix formatting issue:
+ # OR url = base_url.format(version)
+ url = base_url.format(version)
+ print(f"Processing version {version}")
+
+ try:
+ # Set a timeout to avoid hanging requests
+ response = requests.get(url, timeout=5)
+ response.raise_for_status() # Raise exception for non-200 status codes
+
+ soup = BeautifulSoup(response.content, 'html.parser')
+ content = soup.find('div', class_='content')
+
+ # Iterate through each section starting with an H4 element
+ for section in content.find_all('h4'):
+ version_str, date_str = section.text.strip().split(' – ')
+ versions[version_str] = chromium_version
+
+ # Process all content elements (including nested ones) until the next H4
+ next_sibling = section.find_next_sibling(
+ lambda tag: tag.name is not None) # Skip text nodes
+
+ # Process content elements
+ update_found = False
+ while next_sibling and next_sibling.name != 'h4':
+ if next_sibling.name == 'ul':
+ for el in next_sibling.find_all('li'):
+ if 'Update Chromium' in el.text.strip():
+ update_found = True
+ break # Stop iterating after finding update
+
+ # Assign Chromium version only if update is found
+ if update_found:
+ chromium_version = el.text.strip().split()[-1]
+
+ next_sibling = next_sibling.find_next_sibling(
+ lambda tag: tag.name is not None) # Skip text nodes
+
+ # Handle missing Chromium version
+ if not chromium_version:
+ chromium_version = "unknown"
+
+ except requests.exceptions.RequestException as e:
+ if e.args and e.args[0] == 404:
+ print(f"Version {version} not found (404)")
+ else:
+ print(f"Error fetching data for version {version}: {e}")
+ chromium_version = None # Reset chromium_version for next iteration
+
+ except Exception as e: # Catch other unexpected exceptions
+ print(f"Unexpected error: {e}")
+ chromium_version = None # Reset chromium_version for next iteration
+
+ return versions
+
+
+def remediate_unknown_versions(versions):
+ """
+ Remediates entries with "unknown" values in the versions dictionary by
+ assuming no change from the previous known version.
+
+ Args:
+ versions: A dictionary mapping Opera version to Chromium version.
+
+ Returns:
+ The modified versions dictionary with "unknown" values replaced based on previous entries.
+ """
+ previous_version = None
+ for version, chromium_version in versions.items():
+ if chromium_version == "unknown":
+ if previous_version is not None:
+ # Update with previous version
+ versions[version] = previous_version
+ else:
+ previous_version = chromium_version # Update known version for future references
+ return versions
+
+
+# Example usage
+# Base URL with version placeholder
+base_url = "https://blogs.opera.com/desktop/changelog-for-{}/"
+opera_chromium_versions = get_opera_chromium_versions(base_url, 100, 108)
+
+opera_chromium_versions = remediate_unknown_versions(opera_chromium_versions)
+
+if opera_chromium_versions:
+ for opera_version, chromium_version in opera_chromium_versions.items():
+ print(
+ f"Opera Version: {opera_version}, Chromium Version: {chromium_version}")
+else:
+ print("Failed to extract any versions.")
next reply other threads:[~2024-03-20 21:45 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 21:45 Matt Jolly [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-10-23 3:50 [gentoo-commits] proj/chromium-tools:master commit in: / Matt Jolly
2024-10-23 3:50 Matt Jolly
2024-10-10 21:52 Matt Jolly
2024-10-10 10:03 Matt Jolly
2024-09-27 0:52 Matt Jolly
2024-09-27 0:52 Matt Jolly
2024-09-27 0:52 Matt Jolly
2024-09-26 7:25 Matt Jolly
2024-09-26 5:29 Matt Jolly
2024-09-26 5:21 Matt Jolly
2024-09-26 3:03 Matt Jolly
2024-09-26 2:39 Matt Jolly
2024-09-26 2:36 Matt Jolly
2024-08-30 3:39 Matt Jolly
2024-06-01 7:22 Matt Jolly
2024-05-31 23:02 Matt Jolly
2024-03-28 2:39 Matt Jolly
2024-03-20 21:45 Matt Jolly
2024-03-20 21:45 Matt Jolly
2024-03-20 21:45 Matt Jolly
2023-02-05 15:09 Stephan Hartmann
2022-09-01 19:33 Mike Gilbert
2022-09-01 19:24 Mike Gilbert
2022-05-06 9:55 Stephan Hartmann
2022-05-03 16:54 Mike Gilbert
2022-05-03 16:54 Mike Gilbert
2022-02-11 17:16 Stephan Hartmann
2022-02-05 16:29 Stephan Hartmann
2022-01-31 20:20 Stephan Hartmann
2020-11-21 19:34 Stephan Hartmann
2020-10-26 17:48 Mike Gilbert
2016-09-15 16:15 Mike Gilbert
2016-09-15 16:11 Mike Gilbert
2015-08-13 20:53 Mike Gilbert
2012-07-31 23:27 Mike Gilbert
2012-07-31 20:39 Mike Gilbert
2012-06-18 7:38 Paweł Hajdan
2011-10-25 16:36 Paweł Hajdan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1710971104.8e0913a8a053444ee7f68cabb2075c5efbd1e246.kangie@gentoo \
--to=kangie@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox