Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add launchpad source #275

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions nvchecker_source/launchpad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# MIT Licensed
# Copyright (c) 2024 Bert Peters <[email protected]>, et al.
from __future__ import annotations
from nvchecker.api import AsyncCache, Entry, RichResult

PROJECT_INFO_URL = "https://api.launchpad.net/1.0/{launchpad}"

async def get_version(name: str, conf: Entry, *, cache: AsyncCache, **kwargs):
launchpad = conf["launchpad"]

project_data = await cache.get_json(PROJECT_INFO_URL.format(launchpad=launchpad))
data = await cache.get_json(project_data['releases_collection_link'])

return [
RichResult(version=entry["version"], url=entry["web_link"])
for entry in data["entries"]
]



15 changes: 15 additions & 0 deletions tests/test_launchpad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# MIT Licensed
# Copyright (c) 2024 Bert Peters <[email protected]>, et al.
import pytest
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]

async def test_launchpad(get_version):
version = await get_version(
"sakura",
{
"source": "launchpad",
"launchpad": "sakura",
}
)

assert version == '3.8.7'
Loading