35def response(resp):
36 results = []
37
38 for item in resp.json().get('items', []):
39 content = [item.get(i) for i in ['language', 'description'] if item.get(i)]
40
41
42 lic = item.get('license') or {}
43 lic_url = None
44 if lic.get('spdx_id'):
45 lic_url = f"https://spdx.org/licenses/{lic.get('spdx_id')}.html"
46
47 results.append(
48 {
49 'template': 'packages.html',
50 'url': item.get('html_url'),
51 'title': item.get('full_name'),
52 'content': ' / '.join(content),
53 'thumbnail': item.get('owner', {}).get('avatar_url'),
54 'package_name': item.get('name'),
55
56 'maintainer': item.get('owner', {}).get('login'),
57 'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
58 'tags': item.get('topics', []),
59 'popularity': item.get('stargazers_count'),
60 'license_name': lic.get('name'),
61 'license_url': lic_url,
62 'homepage': item.get('homepage'),
63 'source_code_url': item.get('clone_url'),
64 }
65 )
66
67 return results