2"""Repology_ monitors a huge number of package repositories and other sources
3comparing packages versions across them and gathering other information.
5Repology_ shows you in which repositories a given project is packaged, which
6version is the latest and which needs updating, who maintains the package, and
7other related information.
9.. _Repology: https://repology.org/docs/about
14The engine is inactive by default, meaning it is not available in the service.
15If you want to offer the engine, the ``inactive`` flag must be set to ``false``.
26from urllib.parse
import urlencode
33 'website':
'https://repology.org',
34 'wikidata_id':
'Q107409859',
35 'use_official_api':
True,
36 'official_api_documentation':
'https://repology.org/api/v1',
37 'require_api_key':
False,
40categories: list[str] = [
'packages',
'it']
41base_url: str =
'https://repology.org'
44def request(query: str, params: dict[str, t.Any]) ->
None:
48 params[
'url'] = f
"{base_url}/api/v1/projects/?{urlencode(args)}"
52 counts: dict[str |
None, int] = {}
55 counts[item] = counts.get(item, 0) + 1
59 return max(counts, key=counts.get)
63 return [x
for xs
in xss
for x
in xs]
66def response(resp:
'SXNG_Response') -> EngineResults:
69 resp_json = resp.json()
70 for pkgname, repositories
in resp_json.items():
75 for repo
in repositories:
76 if repo.get(
"status") ==
"newest":
77 latest_version = repo[
"version"]
80 latest_version =
_get_most_common([repo.get(
"version")
for repo
in repositories])
83 res.types.LegacyResult(
84 template=
'packages.html',
85 url=f
"{base_url}/project/{pkgname}/versions",
88 package_name=
_get_most_common([pkg.get(
"visiblename")
for pkg
in repositories]),
89 version=latest_version,
91 tags=list({pkg.get(
"repo")
for pkg
in repositories}),
None request(str query, dict[str, t.Any] params)
str|None _get_most_common(list[str|None] items)
EngineResults response('SXNG_Response' resp)