nvchecker.api — The source plugin API¶
- exception nvchecker.api.TemporaryError(code, message, response)[source]¶
A temporary error (e.g. network error) happens.
- class nvchecker.api.BaseWorker(task_sem: Semaphore, result_q: Queue[RawResult], tasks: List[Tuple[str, Dict[str, Any]]], keymanager: KeyManager)[source]¶
The base class for defining
Workerclasses for source plugins.- task_sem: asyncio.Semaphore¶
This is the rate-limiting semaphore. Workers should acquire it while doing one unit of work.
- tasks: List[Tuple[str, Entry]]¶
A list of tasks for the
Workerto complete. Every task consists of a tuple for the task name (table name in the configuration file) and the content of that table (as adict).
- keymanager: KeyManager¶
The
KeyManagerfor retrieving keys from the keyfile.
- class nvchecker.api.RawResult(name: str, version: VersionResult, conf: Entry)[source]¶
The unprocessed result from a check.
Create new instance of RawResult(name, version, conf)
- conf: Dict[str, Any]¶
The entry configuration (table content) of the entry.
- name: str¶
The name (table name) of the entry.
- version: None | str | RichResult | List[str | RichResult] | Exception¶
The result from the check.
- class nvchecker.api.RichResult(*, version: str, gitref: str | None = None, revision: str | None = None, url: str | None = None)[source]¶
RichResult(*, version: ‘str’, gitref: ‘Optional[str]’ = None, revision: ‘Optional[str]’ = None, url: ‘Optional[str]’ = None)
- gitref: str | None = None¶
- revision: str | None = None¶
- url: str | None = None¶
- version: str¶
- class nvchecker.api.AsyncCache[source]¶
A cache for use with async functions.
- async get(key: Hashable, func: Callable[[Hashable], Coroutine[Any, Any, Any]]) Any[source]¶
Run async
funcand cache its return value bykey.The
keyshould be hashable, and the function will be called with it as its sole argument. For multiple simultaneous calls with the same key, only one will actually be called, and others will wait and return the same (cached) value.
- async get_json(url: str, *, headers: Dict[str, str] = {}) Any[source]¶
Get specified
urland return the response content as JSON.The returned data will be cached for reuse.
- cache: Dict[Hashable, Any]¶
- lock: Lock¶
- exception nvchecker.api.GetVersionError(msg: LiteralString, **kwargs: Any)[source]¶
An error occurred while getting version information.
Raise this when a known bad situation happens.
- Parameters:
msg – The error message.
kwargs – Arbitrary additional context for the error.
- nvchecker.api.session: nvchecker.httpclient.base.BaseSession¶
The object to send out HTTP requests, respecting various options in the configuration entry.
- class nvchecker.httpclient.base.Response(headers: Mapping[str, str], body: bytes)[source]¶
The response of an HTTP request.
- body: bytes¶
- headers: Mapping[str, str]¶
- nvchecker.api.proxy = <ContextVar name='proxy' default=None>¶
- nvchecker.api.user_agent = <ContextVar name='user_agent' default='lilydjwg/nvchecker 2.19'>¶
- nvchecker.api.tries = <ContextVar name='tries' default=1>¶
- nvchecker.api.verify_cert = <ContextVar name='verify_cert' default=True>¶
- nvchecker.api.entry_waiter: contextvars.ContextVar¶
This
ContextVarcontains anEntryWaiterinstance for waiting on other entries.