wads.licensing¶
Licensing
Functions
|
|
get_licenses_json_from_github You need to have a github token placed in the right place for this! See pygithub for details. |
|
|
|
|
|
|
|
|
The |
|
Resolve the author name following a priority chain. |
|
Replace placeholders in license text with actual values. |
- wads.licensing.get_licenses_from_github()[source]¶
get_licenses_json_from_github You need to have a github token placed in the right place for this! See pygithub for details.
license_jsons = get_licenses_json_from_github()
- wads.licensing.require_license(license)[source]¶
The
license_infooflicense, or aValueErrornaming the closest keys.licenseis a key, name or SPDX id, in any case, or a namewads.toml_util.pep639_license()knows (Apache Software License). An unknown one used to print the key list and carry on to write an empty LICENSE (issue #237).>>> require_license("mit")["spdx_id"], require_license("APACHE-2.0")["key"] ('MIT', 'apache-2.0') >>> require_license("Apache Software License")["key"] 'apache-2.0' >>> require_license("apach") Traceback (most recent call last): ... ValueError: 'apach' is not a valid licence key; closest: apache-2.0 (...
- Return type:
- wads.licensing.resolve_author(author=None, pyproject_authors=None, url=None)[source]¶
Resolve the author name following a priority chain.
Priority order:
If author is explicitly provided, use it
If pyproject_authors is provided, use the first author’s name
If url is a GitHub URL, extract the org/user from it
If WADS_DFLT_AUTHOR env variable is set, use it
Return placeholder if nothing else works
- Parameters:
- Return type:
- Returns:
Resolved author name or placeholder
>>> resolve_author(author='John Doe') 'John Doe' >>> resolve_author(pyproject_authors=[{'name': 'Jane Smith'}]) 'Jane Smith' >>> resolve_author(url='https://github.com/myorg/myrepo') 'myorg'
- wads.licensing.substitute_license_placeholders(license_text, author=None, year=None)[source]¶
Replace placeholders in license text with actual values.
Common placeholders:
[yyyy], [year] -> current year
[fullname], [name of copyright owner] -> author name
-> © (optional enhancement)
- Parameters:
- Return type:
- Returns:
License text with substituted values
>>> text = "Copyright [yyyy] [fullname]" >>> result = substitute_license_placeholders(text, author='John', year=2025) >>> result 'Copyright 2025 John'