pychoosealicense

Provides license metadata from choosealicense.com.

Classes:

License(title, spdx_id, description, how, …)

Represents a license, with its text and associated metadata.

Functions:

get_license(identifier)

Return the license text and metadata for the given identifier.

get_license(identifier)[source]

Return the license text and metadata for the given identifier.

Parameters

identifier (str)

Return type

License

class License(title, spdx_id, description, how, conditions, permissions, limitations, content, featured=False, hidden=True, nickname=None, note=None)[source]

Bases: tuple

Represents a license, with its text and associated metadata.

Changed in version 0.2.0: conditions, permissions and limitations are now tuples rather than lists to maintain immutability of the License object.

Methods:

__repr__()

Return a string representation of the License.

Attributes:

conditions

Bulleted list of required rules.

content

The text of the license.

description

A human-readable description of the license.

featured

Whether the license is be featured on the choosealicense.com main page.

hidden

Whether the license is neither popular nor fills out the spectrum of licenses from strongly conditional to unconditional.

how

Instructions on how to implement the license.

limitations

Bulleted list of limited rules.

nickname

Customary short name if applicable (e.g, GPLv3)

note

Additional information about the licenses

permissions

Bulleted list of permitted rules.

spdx_id

Short identifier specified by https://spdx.org/licenses/

title

The license full name specified by https://spdx.org/licenses/

__repr__()[source]

Return a string representation of the License.

Return type

str

conditions

Type:    Tuple[Rule, …]

Bulleted list of required rules.

content

Type:    str

The text of the license.

description

Type:    str

A human-readable description of the license.

featured

Type:    bool

Whether the license is be featured on the choosealicense.com main page.

hidden

Type:    bool

Whether the license is neither popular nor fills out the spectrum of licenses from strongly conditional to unconditional.

how

Type:    str

Instructions on how to implement the license.

limitations

Type:    Tuple[Rule, …]

Bulleted list of limited rules.

nickname

Type:    Optional[str]

Customary short name if applicable (e.g, GPLv3)

note

Type:    Optional[str]

Additional information about the licenses

permissions

Type:    Tuple[Rule, …]

Bulleted list of permitted rules.

spdx_id

Type:    str

Short identifier specified by https://spdx.org/licenses/

title

Type:    str

The license full name specified by https://spdx.org/licenses/

The content attribute of License can be populated with project-specific metadata using the str.format() method:

l = get_license("MIT")
l.format(year=2021, fullname="Dominic Davis-Foster")

The supported fields as as follows. Note that not all licenses support all fields.

  • fullname – The full name or username of the repository owner

  • login – The repository owner’s username

  • email – The repository owner’s primary email address

  • project – The repository name

  • description – The description of the repository

  • year – The current year

  • projecturl – The repository URL or other project website