File: combiner.py

package info (click to toggle)
python-nvchecker 2.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 736 kB
  • sloc: python: 4,801; makefile: 25
file content (21 lines) | stat: -rw-r--r-- 539 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
# MIT licensed
# Copyright (c) 2021 lilydjwg <lilydjwg@gmail.com>, et al.

import asyncio
import string

from nvchecker.api import entry_waiter

class CombineFormat(string.Template):
  idpattern = '[0-9]+'

async def get_version(
  name, conf, *, cache, keymanager=None
):
  t = CombineFormat(conf['format'])
  from_ = conf['from']
  waiter = entry_waiter.get()
  entries = [waiter.wait(name) for name in from_]
  vers = await asyncio.gather(*entries)
  versdict = {str(i+1): v for i, v in enumerate(vers)}
  return t.substitute(versdict)