1
0
Fork 0
This commit is contained in:
Daniel Kukula 2024-05-09 19:07:32 +00:00 committed by GitHub
commit 20c4f05e45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 8 deletions

View File

@ -33,10 +33,8 @@ def response(resp):
results = []
for package in resp.json():
meta = package["meta"]
publishedDate = package.get("inserted_at")
if publishedDate:
publishedDate = parser.parse(publishedDate)
tags = meta.get("licenses", [])
published_date = package.get("updated_at")
published_date = parser.parse(published_date)
results.append(
{
"template": "packages.html",
@ -46,11 +44,24 @@ def response(resp):
"content": meta.get("description", ""),
"version": meta.get("latest_version"),
"maintainer": ", ".join(meta.get("maintainers", [])),
"publishedDate": publishedDate,
"tags": tags,
"homepage": meta.get("links", {}).get("homepage"),
"source_code_url": meta.get("links", {}).get("github"),
"publishedDate": published_date,
"license_name": ", ".join(meta.get("licenses", [])),
"homepage": package["docs_html_url"],
"source_code_url": get_source_code_url(meta.get("links", {})),
}
)
return results
def get_source_code_url(links):
source_url = None
for k, v in links.items():
if not source_url and k.lower() in ["source", "github", "gitlab"]:
source_url = v
for k, v in links.items():
if not source_url and ("github" in v or "gitlab" in v):
source_url = v
return source_url