implement url results for AUR and PyPI

see https://github.com/lilydjwg/nvchecker/issues/238.
This commit is contained in:
lilydjwg 2023-10-14 14:51:15 +08:00
parent cc4a0cd301
commit bdd025d995
3 changed files with 12 additions and 4 deletions

View File

@ -3,7 +3,7 @@
from .httpclient import session, TemporaryError, HTTPError
from .util import (
Entry, BaseWorker, RawResult, VersionResult,
Entry, BaseWorker, RawResult, VersionResult, RichResult,
AsyncCache, KeyManager, GetVersionError, EntryWaiter,
)
from .sortversion import sort_version_keys

View File

@ -6,7 +6,7 @@ import asyncio
from typing import Iterable, Dict, List, Tuple, Any, Optional
from nvchecker.api import (
session, GetVersionError, VersionResult,
session, GetVersionError, VersionResult, RichResult,
Entry, BaseWorker, RawResult,
)
@ -99,7 +99,10 @@ async def _run_batch_impl(
if strip_release and '-' in version:
version = version.rsplit('-', 1)[0]
ret[name] = version
ret[name] = RichResult(
version = version,
url = f'https://aur.archlinux.org/packages/{name}',
)
return ret

View File

@ -3,6 +3,8 @@
from packaging.version import Version
from nvchecker.api import RichResult
async def get_version(name, conf, *, cache, **kwargs):
package = conf.get('pypi') or name
use_pre_release = conf.get('use_pre_release', False)
@ -18,4 +20,7 @@ async def get_version(name, conf, *, cache, **kwargs):
)[-1]
else:
version = data['info']['version']
return version
return RichResult(
version = version,
url = f'https://pypi.org/project/{package}/{version}/',
)