wads.toml_util
Utilities for reading and writing pyproject.toml files.
- wads.toml_util.get_project_metadata(pkg_dir: str) dict[str, Any][source]
Get the [project] section from pyproject.toml.
- Parameters:
pkg_dir – Path to the package directory
- Returns:
Dictionary containing project metadata
- wads.toml_util.get_project_name(pkg_dir: str) str | None[source]
Get the project name from pyproject.toml.
- Parameters:
pkg_dir – Path to the package directory
- Returns:
Project name or None if not found
- wads.toml_util.get_project_version(pkg_dir: str) str | None[source]
Get the version from pyproject.toml.
- Parameters:
pkg_dir – Path to the package directory
- Returns:
Version string or None if not found
- wads.toml_util.read_pyproject_toml(pkg_dir: str) dict[str, Any][source]
Read pyproject.toml from the specified package directory.
- Parameters:
pkg_dir – Path to the package directory
- Returns:
Dictionary containing the parsed TOML data
- Raises:
ImportError – If tomli/tomllib is not available
FileNotFoundError – If pyproject.toml doesn’t exist
- wads.toml_util.set_project_version(pkg_dir: str, version: str) None[source]
Set the version in pyproject.toml.
- Parameters:
pkg_dir – Path to the package directory
version – New version string
- wads.toml_util.update_project_metadata(pkg_dir: str, **kwargs) None[source]
Update project metadata in pyproject.toml.
- Parameters:
pkg_dir – Path to the package directory
**kwargs – Metadata fields to update
- wads.toml_util.update_project_url(pkg_dir: str, url: str, url_key: str = 'Homepage') None[source]
Update or add a URL in the [project.urls] section of pyproject.toml.
- Parameters:
pkg_dir – Path to the package directory
url – The URL to set
url_key – The key to use in the urls dict (default: “Homepage”)