37def response(resp):
38 '''post-response callback
39 resp: requests response object
40 '''
41 results = []
42 json_resp = resp.json()
43
44 for item in json_resp.get("results", []):
45 image_source = item.get("source")
46 is_official = image_source in ["store", "official"]
47
48 popularity_infos = [f"{item.get('star_count', 0)} stars"]
49
50 architectures = []
51 for rate_plan in item.get("rate_plans", []):
52 pull_count = rate_plan.get("repositories", [{}])[0].get("pull_count")
53 if pull_count:
54 popularity_infos.insert(0, f"{pull_count} pulls")
55 architectures.extend(arch['name'] for arch in rate_plan.get("architectures", []) if arch['name'])
56
57 result = {
58 'template': 'packages.html',
59 'url': base_url + ("/_/" if is_official else "/r/") + item.get("slug", ""),
60 'title': item.get("name"),
61 'content': item.get("short_description"),
62 'thumbnail': item["logo_url"].get("large") or item["logo_url"].get("small"),
63 'package_name': item.get("name"),
64 'maintainer': item["publisher"].get("name"),
65 'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
66 'popularity': ', '.join(popularity_infos),
67 'tags': architectures,
68 }
69 results.append(result)
70
71 return results