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
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