File: pagure.py

package info (click to toggle)
nvchecker 2.19-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 804 kB
  • sloc: python: 5,192; makefile: 30; sh: 27
file content (26 lines) | stat: -rw-r--r-- 670 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# MIT licensed
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, et al.

from nvchecker.api import (
  VersionResult, RichResult, Entry, AsyncCache, KeyManager,
)

PAGURE_URL = 'https://%s/api/0/%s/git/tags?with_commits=true'

async def get_version(
  name: str, conf: Entry, *,
  cache: AsyncCache, keymanager: KeyManager,
  **kwargs,
) -> VersionResult:
  repo = conf['pagure']
  host = conf.get('host', "pagure.io")

  url = PAGURE_URL % (host, repo)

  data = await cache.get_json(url)
  return [
    RichResult(
      version = version,
      url = f'https://{host}/{repo}/tree/{version_hash}',
    ) for version, version_hash in data["tags"].items()
  ]