forked from Icycoide/searxng
[pylint] add scripts from searxng_extra/update to pylint
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
ffea5d8ef5
commit
295876abaa
5 changed files with 49 additions and 38 deletions
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# lint: pylint
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
"""Fetch firefox useragent signatures
|
||||
|
@ -9,20 +10,21 @@ Output file: :origin:`searx/data/useragents.json` (:origin:`CI Update data ...
|
|||
"""
|
||||
|
||||
import json
|
||||
import requests
|
||||
import re
|
||||
from os.path import dirname, join
|
||||
from os.path import join
|
||||
from urllib.parse import urlparse, urljoin
|
||||
from distutils.version import LooseVersion, StrictVersion
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
import requests
|
||||
from lxml import html
|
||||
from searx import searx_dir
|
||||
|
||||
URL = 'https://ftp.mozilla.org/pub/firefox/releases/'
|
||||
RELEASE_PATH = '/pub/firefox/releases/'
|
||||
|
||||
NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?$')
|
||||
# BETA_REGEX = re.compile('.*[0-9]b([0-9\-a-z]+)$')
|
||||
# ESR_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?esr$')
|
||||
NORMAL_REGEX = re.compile(r'^[0-9]+\.[0-9](\.[0-9])?$')
|
||||
# BETA_REGEX = re.compile(r'.*[0-9]b([0-9\-a-z]+)$')
|
||||
# ESR_REGEX = re.compile(r'^[0-9]+\.[0-9](\.[0-9])?esr$')
|
||||
|
||||
#
|
||||
useragents = {
|
||||
|
@ -39,20 +41,19 @@ def fetch_firefox_versions():
|
|||
resp = requests.get(URL, timeout=2.0)
|
||||
if resp.status_code != 200:
|
||||
raise Exception("Error fetching firefox versions, HTTP code " + resp.status_code)
|
||||
else:
|
||||
dom = html.fromstring(resp.text)
|
||||
versions = []
|
||||
dom = html.fromstring(resp.text)
|
||||
versions = []
|
||||
|
||||
for link in dom.xpath('//a/@href'):
|
||||
url = urlparse(urljoin(URL, link))
|
||||
path = url.path
|
||||
if path.startswith(RELEASE_PATH):
|
||||
version = path[len(RELEASE_PATH) : -1]
|
||||
if NORMAL_REGEX.match(version):
|
||||
versions.append(LooseVersion(version))
|
||||
for link in dom.xpath('//a/@href'):
|
||||
url = urlparse(urljoin(URL, link))
|
||||
path = url.path
|
||||
if path.startswith(RELEASE_PATH):
|
||||
version = path[len(RELEASE_PATH) : -1]
|
||||
if NORMAL_REGEX.match(version):
|
||||
versions.append(LooseVersion(version))
|
||||
|
||||
list.sort(versions, reverse=True)
|
||||
return versions
|
||||
list.sort(versions, reverse=True)
|
||||
return versions
|
||||
|
||||
|
||||
def fetch_firefox_last_versions():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue