plesty.sdk.commands.license

Commands for maintaining SPDX license headers with the REUSE tool.

Python sources carry inline SPDX headers: a collective SPDX-FileCopyrightText holder (the first [project].authors entry) plus one SPDX-FileContributor line per individual author. Non-code files (docs, assets, the root LICENSE, lockfiles) are covered by REUSE.toml. plesty license update adds a header only to files that do not have one yet, leaving curated (e.g. per-file contributor) headers untouched.

Attributes

_EXCLUDED_DIRS

Functions

license_command(→ None)

Maintain and verify SPDX license headers using the REUSE tool.

update_command(→ None)

Ensure the license text exists and add SPDX headers to unheadered sources.

author_command(→ None)

Add the authors of unpushed commits as contributors to the files they changed.

lint_command(→ None)

Verify the project is compliant with the REUSE specification.

_get_project_section(→ dict[str, Any])

Return the [project] section from pyproject content.

_get_copyright_holder(→ str)

Read the collective copyright holder from the first [project].authors entry.

_get_contributors(→ list[str])

Read individual contributor names from [project].authors after the first.

_get_license_id(→ str)

Read the SPDX license identifier from [project].license.

_ensure_license_text(→ None)

Download the license text into LICENSES/ if it is not already present.

_python_sources(→ list[pathlib.Path])

Return all Python source files, excluding build, cache and hidden dirs.

_run_reuse(→ None)

Run the reuse tool, falling back to python -m reuse if needed.

Module Contents

plesty.sdk.commands.license._EXCLUDED_DIRS
plesty.sdk.commands.license.license_command() → None

Maintain and verify SPDX license headers using the REUSE tool.

Return type:

None

plesty.sdk.commands.license.update_command(context: plesty.sdk.context.ApplicationContext) → None

Ensure the license text exists and add SPDX headers to unheadered sources.

This command:

  1. Reads the copyright holder from the first [project].authors entry and the remaining authors as contributors.

  2. Reads the SPDX license identifier from [project].license.

  3. Ensures the license text exists under LICENSES/.

  4. Runs reuse annotate –skip-existing over Python files, adding a header (collective SPDX-FileCopyrightText plus one SPDX-FileContributor per author) only to files that do not already have one. Curated headers are left unchanged.

Parameters:

context (plesty.sdk.context.ApplicationContext)

Return type:

None

plesty.sdk.commands.license.author_command(context: plesty.sdk.context.ApplicationContext) → None

Add the authors of unpushed commits as contributors to the files they changed.

For every Python file changed by a commit that is not yet pushed, adds the commit author (resolved through .mailmap) as an SPDX-FileContributor, keeping all existing contributors. Review and commit the result before pushing. This is the fix for a failing Authorship Currency gate.

Parameters:

context (plesty.sdk.context.ApplicationContext)

Return type:

None

plesty.sdk.commands.license.lint_command(context: plesty.sdk.context.ApplicationContext) → None

Verify the project is compliant with the REUSE specification.

Parameters:

context (plesty.sdk.context.ApplicationContext)

Return type:

None

plesty.sdk.commands.license._get_project_section(pyproject_toml: dict[str, Any]) → dict[str, Any]

Return the [project] section from pyproject content.

Parameters:

pyproject_toml (dict[str, Any])

Return type:

dict[str, Any]

Read the collective copyright holder from the first [project].authors entry.

Parameters:

project_section (dict[str, Any])

Return type:

str

plesty.sdk.commands.license._get_contributors(project_section: dict[str, Any]) → list[str]

Read individual contributor names from [project].authors after the first.

Parameters:

project_section (dict[str, Any])

Return type:

list[str]

plesty.sdk.commands.license._get_license_id(project_section: dict[str, Any]) → str

Read the SPDX license identifier from [project].license.

Supports the PEP 639 SPDX-expression string form (license = “LGPL-3.0-or-later”) and the legacy table form (license = {text = “…”}).

Parameters:

project_section (dict[str, Any])

Return type:

str

plesty.sdk.commands.license._ensure_license_text(project_root: pathlib.Path, license_id: str) → None

Download the license text into LICENSES/ if it is not already present.

Parameters:
  • project_root (pathlib.Path)

  • license_id (str)

Return type:

None

plesty.sdk.commands.license._python_sources(project_root: pathlib.Path) → list[pathlib.Path]

Return all Python source files, excluding build, cache and hidden dirs.

Parameters:

project_root (pathlib.Path)

Return type:

list[pathlib.Path]

plesty.sdk.commands.license._run_reuse(args: list[str], project_root: pathlib.Path) → None

Run the reuse tool, falling back to python -m reuse if needed.

Parameters:
  • args (list[str])

  • project_root (pathlib.Path)

Return type:

None