pyproject_parser.classes¶
Classes to represent readme and license files.
Classes:
|
Represents a license in PEP 621 configuration. |
|
Represents a readme in PEP 621 configuration. |
Data:
Invariant |
|
Invariant |
-
class
License(file=None, text=None, expression=None)[source]¶ Bases:
objectRepresents a license in PEP 621 configuration.
- Parameters
Changed in version 0.14.0: Add
expressionoption.Attributes:
An SPDX License Expression (for PEP 639).
The path to the license file.
The content of the license.
Methods:
from_dict(data)Construct a
Licensefrom a dictionary containing the same keys as the class constructor.resolve([inplace])Retrieve the contents of the license file if the
fileis set.to_dict()Construct a dictionary containing the keys of the
Licenseobject.Construct a dictionary containing the keys of the
Licenseobject, suitable for use in PEP 621pyproject.tomlconfiguration.Construct a dictionary or string representing the
Licenseobject, suitable for use in PEP 639-compatiblepyproject.tomlconfiguration.-
classmethod
from_dict(data)[source]¶ Construct a
Licensefrom a dictionary containing the same keys as the class constructor.Functionally identical to
License(**data)but provided to give an identical API toReadme.See also
-
resolve(inplace=False)[source]¶ Retrieve the contents of the license file if the
fileis set.Returns a new
Licenseobject withtextset to the content of the file.
-
class
Readme(content_type=None, charset='UTF-8', file=None, text=None)[source]¶ Bases:
objectRepresents a readme in PEP 621 configuration.
- Parameters
content_type (
Optional[Literal['text/markdown','text/x-rst','text/plain']]) – The content type of the readme. DefaultNone.charset (
str) – The charset / encoding of the readme. Default'UTF-8'.file (
Union[str,Path,PathLike,None]) – The path to the license file. DefaultNone.text (
Optional[str]) – The content of the license. DefaultNone.
Attributes:
The charset / encoding of the readme.
The content type of the readme.
The path to the readme file.
The content of the readme.
Methods:
from_dict(data)Construct a
Readmefrom a dictionary containing the same keys as the class constructor.from_file(file[, charset])Create a
Readmefrom a filename.resolve([inplace])Retrieve the contents of the readme file if the
self.fileis set.to_dict()Construct a dictionary containing the keys of the
Readmeobject.Construct a dictionary containing the keys of the
Readmeobject, suitable for use in PEP 621pyproject.tomlconfiguration.-
content_type¶ Type:
Optional[Literal['text/markdown','text/x-rst','text/plain']]The content type of the readme.
-
classmethod
from_dict(data)[source]¶ Construct a
Readmefrom a dictionary containing the same keys as the class constructor.In addition,
content_typemay instead be given ascontent-type.- Parameters
data (
ReadmeDict)- Return type
See also
-
resolve(inplace=False)[source]¶ Retrieve the contents of the readme file if the
self.fileis set.Returns a new
Readmeobject withtextset to the content of the file.
-
to_dict()[source]¶ Construct a dictionary containing the keys of the
Readmeobject.See also
- Return type
-
to_pep621_dict()[source]¶ Construct a dictionary containing the keys of the
Readmeobject, suitable for use in PEP 621pyproject.tomlconfiguration.Unlike
to_dict()this ignores thetextkey ifself.fileis set, and ignoresself.content_typeif it matches the content-type inferred from the file extension.See also
-
_L= TypeVar(_L, bound=License)¶ Type:
TypeVarInvariant
TypeVarbound topyproject_parser.classes.License.
-
_R= TypeVar(_R, bound=Readme)¶ Type:
TypeVarInvariant
TypeVarbound topyproject_parser.classes.Readme.