pyTooling.Licensing

The Licensing module implements mapping tables for various license names and identifiers.

Hint

See high-level help for explanations and usage examples.

Variables

Classes

  • PythonLicenseName: A data class to represent the license’s short name and the package classifier for a license.

  • License: Representation of a license.


Variables

pyTooling.Licensing.PYTHON_LICENSE_NAMES

Mapping of SPDX identifiers to Python license names

{'Apache-2.0': PythonLicenseName(ShortName='Apache 2.0',
                                 Classifier='Apache Software License'),
 'BSD-3-Clause': PythonLicenseName(ShortName='BSD', Classifier='BSD License'),
 'GPL-2.0-or-later': PythonLicenseName(ShortName='GPL-2.0-or-later',
                                       Classifier='GNU General Public License '
                                                  'v2 or later (GPLv2+)'),
 'MIT': PythonLicenseName(ShortName='MIT', Classifier='MIT License')}
pyTooling.Licensing.Apache_2_0_License

Representation of a license.

Apache-2.0
pyTooling.Licensing.BSD_3_Clause_License

Representation of a license.

BSD-3-Clause
pyTooling.Licensing.GPL_2_0_or_later

Representation of a license.

GPL-2.0-or-later
pyTooling.Licensing.MIT_License

Representation of a license.

MIT
pyTooling.Licensing.SPDX_INDEX

Mapping of predefined licenses

{'Apache-2.0': Apache-2.0,
 'BSD-3-Clause': BSD-3-Clause,
 'GPL-2.0-or-later': GPL-2.0-or-later,
 'MIT': MIT}

Classes

class pyTooling.Licensing.PythonLicenseName(ShortName, Classifier)[source]

A data class to represent the license’s short name and the package classifier for a license.

Inheritance

Inheritance diagram of PythonLicenseName

Parameters:
  • ShortName (str)

  • Classifier (str)

ShortName: str

License’s short name

Classifier: str

Package classifier for a license.

__str__()[source]

The string representation of this name tuple returns the short name of the license.

Return type:

str

Returns:

Short name of the license.

__eq__(other)

Return self==value.

__hash__ = None
__init__(ShortName, Classifier)
Parameters:
  • ShortName (str)

  • Classifier (str)

Return type:

None

__repr__()

Return repr(self).

class pyTooling.Licensing.License(spdxIdentifier, name, osiApproved=False, fsfApproved=False)[source]

Representation of a license.

Inheritance

Inheritance diagram of License

Parameters:
  • spdxIdentifier (str)

  • name (str)

  • osiApproved (bool)

  • fsfApproved (bool)

__init__(spdxIdentifier, name, osiApproved=False, fsfApproved=False)[source]
Parameters:
  • spdxIdentifier (str)

  • name (str)

  • osiApproved (bool)

  • fsfApproved (bool)

_spdxIdentifier: str

Unique SPDX identifier.

_name: str

Name of the license.

_osiApproved: bool

OSI approval status

_fsfApproved: bool

FSF approval status

property Name: str

Returns the license’ name.

Returns:

License name.

property SPDXIdentifier: str

Returns the license’ unique SPDX identifier.

Returns:

The the unique SPDX identifier.

property OSIApproved: bool

Returns true, if the license is approved by OSI (Open Source Initiative).

Returns:

True, if the license is approved by the Open Source Initiative.

property FSFApproved: bool

Returns true, if the license is approved by FSF (Free Software Foundation).

Returns:

True, if the license is approved by the Free Software Foundation.

property PythonLicenseName: str

Returns the Python license name for this license if it’s defined.

Returns:

The Python license name.

Raises:

ValueError – If there is no license name defined for the license.
(See and check PYTHON_LICENSE_NAMES)

property PythonClassifier: str

Returns the Python package classifier for this license if it’s defined.

Returns:

The Python package classifier.

Raises:

ValueError – If there is no classifier defined for the license.
(See and check PYTHON_LICENSE_NAMES)

See also

List of Python classifiers

__eq__(other)[source]

Returns true, if both licenses are identical (comparison based on SPDX identifiers).

Return type:

bool

Returns:

True, if both licenses are identical.

Raises:

TypeError – If second operand is not of type License or str.

Parameters:

other (Any)

__ne__(other)[source]

Returns true, if both licenses are not identical (comparison based on SPDX identifiers).

Return type:

bool

Returns:

True, if both licenses are not identical.

Raises:

TypeError – If second operand is not of type License or str.

Parameters:

other (Any)

__le__(other)[source]

Returns true, if both licenses are compatible.

Return type:

bool

Parameters:

other (Any)

__ge__(other)[source]

Returns true, if both licenses are compatible.

Return type:

bool

Parameters:

other (Any)

__repr__()[source]

Returns the internal unique representation (a.k.a SPDX identifier).

Return type:

str

Returns:

SPDX identifier of the license.

__str__()[source]

Returns the license’ name.

Return type:

str

Returns:

Name of the license.

class property HasClassAttributes: bool

Check if class has Attributes.

Returns:

True, if the class has Attributes.

class property HasMethodAttributes: bool

Check if class has any method with Attributes.

Returns:

True, if the class has any method with Attributes.

__hash__ = None