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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['packages', 'it']
 
str base_url = "https://xq-api.voidlinux.org"
 
str pkg_repo_url = "https://github.com/void-linux/void-packages"
 
str void_arch = 'x86_64'
 
 ARCH_RE = re.compile('aarch64-musl|armv6l-musl|armv7l-musl|x86_64-musl|aarch64|armv6l|armv7l|i686|x86_64')
 

Detailed Description

SearXNG engine for `Void Linux binary packages`_.  Void is a general purpose
operating system, based on the monolithic Linux kernel. Its package system
allows you to quickly install, update and remove software; software is provided
in binary packages or can be built directly from sources with the help of the
XBPS source packages collection.

.. _Void Linux binary packages: https://voidlinux.org/packages/

Function Documentation

◆ request()

searx.engines.voidlinux.request ( query,
params )

Definition at line 38 of file voidlinux.py.

38def request(query, params):
39 arch_path = ARCH_RE.search(query)
40 if arch_path:
41 arch_path = arch_path.group(0)
42 query = query.replace(arch_path, '').strip()
43 else:
44 arch_path = void_arch
45
46 params['url'] = f"{base_url}/v1/query/{arch_path}?q={quote_plus(query)}"
47 return params
48
49

◆ response()

searx.engines.voidlinux.response ( resp)
At Void Linux, several packages sometimes share the same source code
(template) and therefore also have the same URL.  Results with identical
URLs are merged as one result for SearXNG.

Definition at line 50 of file voidlinux.py.

50def response(resp):
51 """
52 At Void Linux, several packages sometimes share the same source code
53 (template) and therefore also have the same URL. Results with identical
54 URLs are merged as one result for SearXNG.
55 """
56
57 packages = {}
58 for result in resp.json()['data']:
59
60 # 32bit and dbg packages don't have their own package templates
61 github_slug = re.sub(r"-(32bit|dbg)$", "", result['name'])
62 pkg_url = f"{pkg_repo_url}/tree/master/srcpkgs/{github_slug}"
63
64 pkg_list = packages.get(pkg_url, [])
65 pkg_list.append(
66 {
67 'title': result['name'],
68 'content': f"{result['short_desc']} - {humanize_bytes(result['filename_size'])}",
69 'package_name': result['name'],
70 'version': f"v{result['version']}_{result['revision']}",
71 'tags': result['repository'],
72 }
73 )
74 packages[pkg_url] = pkg_list
75
76 results = []
77 for pkg_url, pkg_list in packages.items():
78
79 results.append(
80 {
81 'url': pkg_url,
82 'template': 'packages.html',
83 'title': ' | '.join(x['title'] for x in pkg_list),
84 'content': pkg_list[0]['content'],
85 'package_name': ' | '.join(x['package_name'] for x in pkg_list),
86 'version': pkg_list[0]['version'],
87 'tags': [x['tags'] for x in pkg_list],
88 }
89 )
90 return results

Variable Documentation

◆ about

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

Definition at line 17 of file voidlinux.py.

◆ ARCH_RE

searx.engines.voidlinux.ARCH_RE = re.compile('aarch64-musl|armv6l-musl|armv7l-musl|x86_64-musl|aarch64|armv6l|armv7l|i686|x86_64')

Definition at line 34 of file voidlinux.py.

◆ base_url

str searx.engines.voidlinux.base_url = "https://xq-api.voidlinux.org"

Definition at line 28 of file voidlinux.py.

◆ categories

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

Definition at line 26 of file voidlinux.py.

◆ pkg_repo_url

str searx.engines.voidlinux.pkg_repo_url = "https://github.com/void-linux/void-packages"

Definition at line 29 of file voidlinux.py.

◆ void_arch

str searx.engines.voidlinux.void_arch = 'x86_64'

Definition at line 31 of file voidlinux.py.