letsbuilda.pypi

A wrapper for PyPI’s API and RSS feed.

Submodules

Exceptions

PackageNotFoundError

Raised when a package is not found.

Classes

JSONPackageMetadata

Package metadata.

Package

Metadata for a package.

RSSPackageMetadata

RSS Package metadata.

PyPIServices

A class for interacting with PyPI.

Package Contents

exception letsbuilda.pypi.PackageNotFoundError(package_title: str, package_version: str | None)[source]

Bases: Exception

Raised when a package is not found.

package_title[source]
package_version[source]
class letsbuilda.pypi.JSONPackageMetadata(/, **data: Any)[source]

Bases: pydantic.BaseModel

Package metadata.

info: Info[source]
last_serial: int[source]
urls: list[URL][source]
vulnerabilities: list[Vulnerability][source]
class letsbuilda.pypi.Package(/, **data: Any)[source]

Bases: pydantic.BaseModel

Metadata for a package.

title: str[source]
releases: list[Release][source]
class letsbuilda.pypi.RSSPackageMetadata(/, **data: Any)[source]

Bases: pydantic.BaseModel

RSS Package metadata.

title: str[source]
version: str | None[source]
guid: str | None[source]
description: str | None[source]
author: str | None[source]
publication_date: ISODateTime[source]
classmethod try_split_title(data: dict) dict[source]

Attempt to split title into package name and version.

class letsbuilda.pypi.PyPIServices(http_client: httpx.Client)[source]

A class for interacting with PyPI.

NEWEST_PACKAGES_FEED_URL: Final[str] = 'https://pypi.org/rss/packages.xml'[source]
PACKAGE_UPDATES_FEED_URL: Final[str] = 'https://pypi.org/rss/updates.xml'[source]
http_client[source]
get_rss_feed(feed_url: str) list[letsbuilda.pypi.models.RSSPackageMetadata][source]

Get the new packages RSS feed.

Parameters:

feed_url – The URL of the RSS feed.

Returns:

The list of new packages.

Return type:

list[RSSPackageMetadata]

get_package_json_metadata(package_title: str, package_version: str | None = None) letsbuilda.pypi.models.JSONPackageMetadata[source]

Retrieve metadata for a package.

Raises:

PackageNotFoundError – If the package is not found.

Parameters:
  • package_title – The title of the package.

  • package_version – The version of the package.

Returns:

The metadata for the package.

Return type:

JSONPackageMetadata

get_package_metadata(package_title: str, package_version: str | None = None) letsbuilda.pypi.models.Package[source]

Create a Package object from its metadata.

Parameters:
  • package_title – The title of the package.

  • package_version – The version of the package.

Returns:

The package object.

Return type:

Package