plesty.server.services.catalogue
Fetch and search the hub catalogue (hub-registry /api/modules/).
The registry describes a module’s repository and tags; whether its release
reached PyPI is PyPI’s own business, and pypi_release() asks it. That
one request decides a real difference on a bench: a release install needs
nothing but uv, a repository install needs git.
Attributes
Exceptions
The catalogue could not be fetched or read. |
Classes
The hub catalogue at one index URL. |
Functions
|
GET url with the standard library (the bench may have no |
|
The newest release of package on PyPI, or |
|
Module Contents
- plesty.server.services.catalogue.Fetcher
- plesty.server.services.catalogue.PYPI_RELEASE_URL = 'https://pypi.org/pypi/{package}/json'
- exception plesty.server.services.catalogue.CatalogueError
Bases:
RuntimeErrorThe catalogue could not be fetched or read.
Initialize self. See help(type(self)) for accurate signature.
- plesty.server.services.catalogue.http_fetch(url: str, timeout: float = 15.0) bytes
GET url with the standard library (the bench may have no
requests).- Parameters:
url (str)
timeout (float)
- Return type:
bytes
- plesty.server.services.catalogue.pypi_release(package: str, fetch: Fetcher | None = None) str | None
The newest release of package on PyPI, or
Nonewhen it has none there.- Parameters:
package (str) – Distribution name.
fetch (Fetcher | None) – Reads a URL; injected by tests.
- Return type:
str | None
- class plesty.server.services.catalogue.Catalogue(index_url: str | None = None, fetch: Fetcher | None = None)
The hub catalogue at one index URL.
Bind to an index.
- Parameters:
index_url (str | None) –
/api/modules/endpoint; the public hub by default.fetch (Fetcher | None) – Reads a URL; injected by tests.
- index_url = 'https://hub.plesty.net/api/modules/'
- _fetch
- _cache: list[plesty.server.model.catalogue.CatalogueEntry] | None = None
- entries(refresh: bool = False) list[plesty.server.model.catalogue.CatalogueEntry]
Every module the index lists (fetched once, then cached).
- Raises:
CatalogueError – When the index cannot be fetched or is not JSON.
- Parameters:
refresh (bool)
- Return type:
- search(query: str = '', vendor: str = '', category: str = 'devices', standard: str = REQUIRED_STANDARD) list[plesty.server.model.catalogue.CatalogueEntry]
Entries matching query, filtered by vendor, category and standard (
""= any).- Parameters:
query (str)
vendor (str)
category (str)
standard (str)
- Return type:
- vendors(category: str = 'devices') list[str]
The vendor groups present in category.
- Parameters:
category (str)
- Return type:
list[str]
- lookup(package: str) plesty.server.model.catalogue.CatalogueEntry | None
The entry named package (any category, any standard), or
None.- Parameters:
package (str)
- Return type:
- plesty.server.services.catalogue._canonical(name: str) str
- Parameters:
name (str)
- Return type:
str