helpers

Core helpers API reference

Helper functions for the Python versions applet.

Parts borrowed from https://github.com/python/cpython-devcontainers/blob/main/cpython-ci/get_versions.py/ and Barry Warsaw

app.applets.core.helpers.get_db_connection() Connection[source]

Get a database connection.

Yields:

A database connection.

app.applets.core.helpers.initialize_database() None[source]

Initialize the database.

async app.applets.core.helpers.start_periodic_update() None[source]

Start the periodic update task.

async app.applets.core.helpers.periodic_update() None[source]

Periodically update the Python versions in the database.

async app.applets.core.helpers.get_tags_from_github() list[dict][source]

Get the Python tags from the GitHub API.

Returns:

A list of tags.

Return type:

list[dict]

async app.applets.core.helpers.get_version_eols() dict[str, date][source]

Get the Python version EOL dates from endoflife.date.

Returns:

A dictionary

Return type:

dict[str, date]

app.applets.core.helpers.get_version_from_tags(tags: list[dict]) list[Version][source]

Get the Python versions from the GitHub tags.

Parameters:

tags (list[dict]) – A list of tags from the GitHub API.

Returns:

A list of Version objects.

Return type:

list[pkg_version.Version]

app.applets.core.helpers.get_latest_version(all_versions: list[Version]) dict[str, Version][source]

Get the latest Python versions for each series.

Parameters:

all_versions (list[pkg_version.Version]) – A list of Version objects.

Returns:

A dictionary of the latest versions.

Return type:

dict[str, pkg_version.Version]

async app.applets.core.helpers.update_versions_in_db(versions: list[Version]) None[source]

Update the Python versions in the database.

Parameters:

versions (list[Version]) – A list of Version objects to update.

async app.applets.core.helpers.get_versions_from_db() list[Version][source]

Get the latest Python versions from the database.

Returns:

A list of Version objects.

Return type:

list[Version]

async app.applets.core.helpers.fetch_and_update_versions() None[source]

Fetch the latest Python versions from GitHub and update the database.

async app.applets.core.helpers.get_python_versions() list[Version][source]

Get the latest Python versions from the database or fetch them from GitHub if the database is empty or outdated.

Returns:

A list of Version objects.

Return type:

list[Version]

app.applets.core.helpers.generate_app_config(app_config: AppConfig) AppConfig[source]

Configure the Python versions module.

This function is used as an on_app_init handler for Litestar.

Parameters:

app_config – The Litestar AppConfig instance.

Returns:

The updated AppConfig instance.

Return type:

AppConfig