repology_client.utils#

Utility functions and classes.

repology_client.utils.get_type_adapter(t: type[T]) → TypeAdapter#

Get a cached TypeAdapter instance.

Parameters:

t – type

class repology_client.utils.limit(calls: int, period: float)#

Bases: object

Decorator to set a limit on requests per second.

Based on this StackOverflow answer.

async sleep() → None#
repology_client.utils.ensure_session(session: ClientSession | None = None) → AsyncGenerator[ClientSession, None]#

Create a new client session, if necessary, and close it on exit.

Parameters:

session – aiohttp client session

Convert status codes to human-readable messages.

See also

repology_client.get_problems() function

Implements /api/v1/repository/<repo>/problems and /api/v1/maintainer/<maint>/problems-for-repo/<repo> endpoints.

repology_client.types.Problem class

>>> format_link_status(404)
'HTTP 404'
>>> format_link_status(-100)
'connect timeout (60 seconds)'
>>> format_link_status(-999)
'unknown status code -999, please report a bug to repology-client'