File: debianpkg.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 (28 lines) | stat: -rw-r--r-- 870 bytes parent folder | download | duplicates (2)
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
27
28
# MIT licensed
# Copyright (c) 2020 lilydjwg <lilydjwg@gmail.com>, et al.
# Copyright (c) 2017 Felix Yan <felixonmars@archlinux.org>, et al.

from nvchecker.api import RichResult, GetVersionError

URL = 'https://sources.debian.org/api/src/%(pkgname)s/?suite=%(suite)s'

async def get_version(name, conf, *, cache, **kwargs):
  pkg = conf.get('debianpkg') or name
  strip_release = conf.get('strip_release', False)
  suite = conf.get('suite') or "sid"
  url = URL % {"pkgname": pkg, "suite": suite}
  data = await cache.get_json(url)

  if not data.get('versions'):
    raise GetVersionError('Debian package not found')

  r = data['versions'][0]
  if strip_release:
    version = r['version'].split("-")[0]
  else:
    version = r['version']

  return RichResult(
    version = version,
    url = f'https://sources.debian.org/src/{data["package"]}/{r["version"]}/',
  )