sponsorkit.targets

Targets and target sets.

On this page
import sponsorkit.targets

Targets and target sets.

A target is an account a maintainer receives sponsorships on: github:<login> or open-collective:<slug>. A target set is canonical: deduplicated, sorted by string form, with at most one target per provider.

Exports#

NameKindSummary
PROVIDERSconstantEvery supported provider.
Providertype aliasA contribution provider.
TargetclassA normalized target (lowercased, trimmed account).
canonical_targets()functionDeduplicate and sort a target set; at least one target, at most one per provider.
normalize_target()functionValidate and normalize one target.
parse_target()functionParse "github:octocat" into a Target.
targets_from_options()functionBuild a canonical target set from github= / open_collective= handles.
targets_from_param()functionParse a target param such as "github:x,open-collective:y".
targets_hash()functionLowercase hex SHA-256 of the UTF-8 target param (used for storage keys).
targets_param()functionThe canonical target param: the canonical set joined with ,.

Functions#

normalize_target()#

def normalize_target(provider: str, account: str) -> Target

Validate and normalize one target. Raises SponsorkitError("invalid_config").

parse_target()#

def parse_target(value: str) -> Target

Parse "github:octocat" into a Target.

canonical_targets()#

def canonical_targets(targets: Iterable[Target]) -> tuple[Target, ...]

Deduplicate and sort a target set; at least one target, at most one per provider.

targets_from_options()#

def targets_from_options(
    github: str | None = None,
    open_collective: str | None = None,
) -> tuple[Target, ...]

Build a canonical target set from github= / open_collective= handles.

targets_from_param()#

def targets_from_param(param: str) -> tuple[Target, ...]

Parse a target param such as "github:x,open-collective:y".

targets_param()#

def targets_param(targets: Iterable[Target]) -> str

The canonical target param: the canonical set joined with ,.

Also exported as sponsorkit.targets_param.

targets_hash()#

def targets_hash(targets: Iterable[Target]) -> str

Lowercase hex SHA-256 of the UTF-8 target param (used for storage keys).

Also exported as sponsorkit.targets_hash.

Constants#

PROVIDERS#

PROVIDERS: tuple[Provider, ...] = ('github', 'open-collective')

Every supported provider.