sponsorkit.targets
Targets and target sets.
On this page
import sponsorkit.targetsTargets 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#
| Name | Kind | Summary |
|---|---|---|
PROVIDERS | constant | Every supported provider. |
Provider | type alias | A contribution provider. |
Target | class | A normalized target (lowercased, trimmed account). |
canonical_targets() | function | Deduplicate and sort a target set; at least one target, at most one per provider. |
normalize_target() | function | Validate and normalize one target. |
parse_target() | function | Parse "github:octocat" into a Target. |
targets_from_options() | function | Build a canonical target set from github= / open_collective= handles. |
targets_from_param() | function | Parse a target param such as "github:x,open-collective:y". |
targets_hash() | function | Lowercase hex SHA-256 of the UTF-8 target param (used for storage keys). |
targets_param() | function | The canonical target param: the canonical set joined with ,. |
Functions#
normalize_target()#
def normalize_target(provider: str, account: str) -> TargetValidate and normalize one target. Raises SponsorkitError("invalid_config").
parse_target()#
def parse_target(value: str) -> TargetParse "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]) -> strThe canonical target param: the canonical set joined with ,.
Also exported as sponsorkit.targets_param.
targets_hash()#
def targets_hash(targets: Iterable[Target]) -> strLowercase 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.