41def response(resp):
42 results = []
43 content = resp.json()
44 for entry in content["results"]:
45 package = entry["package"]
46 publishedDate = package.get("date")
47 if publishedDate:
48 publishedDate = parser.parse(publishedDate)
49 tags = list(entry.get("flags", {}).keys()) + package.get("keywords", [])
50 results.append(
51 {
52 "template": "packages.html",
53 "url": package["links"]["npm"],
54 "title": package["name"],
55 'package_name': package["name"],
56 "content": package.get("description", ""),
57 "version": package.get("version"),
58 "maintainer": package.get("author", {}).get("name"),
59 'publishedDate': publishedDate,
60 "tags": tags,
61 "homepage": package["links"].get("homepage"),
62 "source_code_url": package["links"].get("repository"),
63 }
64 )
65
66 return results