.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.repology Namespace Reference

Functions

None request (str query, dict[str, t.Any] params)
str|None _get_most_common (list[str|None] items)
 _flatten (xss)
EngineResults response ('SXNG_Response' resp)

Variables

dict about
list categories = ['packages', 'it']
str base_url = 'https://repology.org'

Detailed Description

Repology_ monitors a huge number of package repositories and other sources
comparing packages versions across them and gathering other information.

Repology_ shows you in which repositories a given project is packaged, which
version is the latest and which needs updating, who maintains the package, and
other related information.

.. _Repology: https://repology.org/docs/about

Configuration
=============

The engine is inactive by default, meaning it is not available in the service.
If you want to offer the engine, the ``inactive`` flag must be set to ``false``.

.. code:: yaml

  - name: repology
    inactive: false

Function Documentation

◆ _flatten()

searx.engines.repology._flatten ( xss)
protected

Definition at line 62 of file repology.py.

62def _flatten(xss):
63 return [x for xs in xss for x in xs]
64
65

Referenced by response().

Here is the caller graph for this function:

◆ _get_most_common()

str | None searx.engines.repology._get_most_common ( list[str | None] items)
protected

Definition at line 51 of file repology.py.

51def _get_most_common(items: list[str | None]) -> str | None:
52 counts: dict[str | None, int] = {}
53 for item in items:
54 if item:
55 counts[item] = counts.get(item, 0) + 1
56
57 if len(counts) == 0:
58 return None
59 return max(counts, key=counts.get)
60
61

Referenced by response().

Here is the caller graph for this function:

◆ request()

None searx.engines.repology.request ( str query,
dict[str, t.Any] params )

Definition at line 44 of file repology.py.

44def request(query: str, params: dict[str, t.Any]) -> None:
45 args = {
46 'search': query,
47 }
48 params['url'] = f"{base_url}/api/v1/projects/?{urlencode(args)}"
49
50

◆ response()

EngineResults searx.engines.repology.response ( 'SXNG_Response' resp)

Definition at line 66 of file repology.py.

66def response(resp: 'SXNG_Response') -> EngineResults:
67 res = EngineResults()
68
69 resp_json = resp.json()
70 for pkgname, repositories in resp_json.items():
71
72 # either there's a package with status "newest" or we assume that the
73 # most commonly used version is the latest released (non-alpha) version
74 latest_version = None
75 for repo in repositories:
76 if repo.get("status") == "newest":
77 latest_version = repo["version"]
78 break
79 else:
80 latest_version = _get_most_common([repo.get("version") for repo in repositories])
81
82 res.add(
83 res.types.LegacyResult(
84 template='packages.html',
85 url=f"{base_url}/project/{pkgname}/versions",
86 title=pkgname,
87 content=_get_most_common([pkg.get("summary") for pkg in repositories]),
88 package_name=_get_most_common([pkg.get("visiblename") for pkg in repositories]),
89 version=latest_version,
90 license_name=_get_most_common(_flatten([pkg.get("licenses", []) for pkg in repositories])),
91 tags=list({pkg.get("repo") for pkg in repositories}), # ensure that tags are unique
92 )
93 )
94
95 return res

References _flatten(), and _get_most_common().

Here is the call graph for this function:

Variable Documentation

◆ about

dict searx.engines.repology.about
Initial value:
1= {
2 'website': 'https://repology.org',
3 'wikidata_id': 'Q107409859',
4 'use_official_api': True,
5 'official_api_documentation': 'https://repology.org/api/v1',
6 'require_api_key': False,
7 'results': 'JSON',
8}

Definition at line 32 of file repology.py.

◆ base_url

str searx.engines.repology.base_url = 'https://repology.org'

Definition at line 41 of file repology.py.

◆ categories

list searx.engines.repology.categories = ['packages', 'it']

Definition at line 40 of file repology.py.