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)[source]¶ Bases:
object
Represents a license in PEP 621 configuration.
- Parameters
Attributes:
Methods:
from_dict
(data)Construct a
License
from a dictionary containing the same keys as the class constructor.resolve
([inplace])Retrieve the contents of the license file if the
file
is set.to_dict
()Construct a dictionary containing the keys of the
License
object.Construct a dictionary containing the keys of the
License
object, suitable for use in PEP 621pyproject.toml
configuration.-
classmethod
from_dict
(data)[source]¶ Construct a
License
from 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
file
is set.Returns a new
License
object withtext
set to the content of the file.
-
class
Readme
(content_type=None, charset='UTF-8', file=None, text=None)[source]¶ Bases:
object
Represents 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
Readme
from a dictionary containing the same keys as the class constructor.from_file
(file[, charset])Create a
Readme
from a filename.resolve
([inplace])Retrieve the contents of the readme file if the
self.file
is set.to_dict
()Construct a dictionary containing the keys of the
Readme
object.Construct a dictionary containing the keys of the
Readme
object, suitable for use in PEP 621pyproject.toml
configuration.-
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
Readme
from a dictionary containing the same keys as the class constructor.In addition,
content_type
may 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.file
is set.Returns a new
Readme
object withtext
set to the content of the file.
-
to_dict
()[source]¶ Construct a dictionary containing the keys of the
Readme
object.See also
- Return type
-
to_pep621_dict
()[source]¶ Construct a dictionary containing the keys of the
Readme
object, suitable for use in PEP 621pyproject.toml
configuration.Unlike
to_dict()
this ignores thetext
key ifself.file
is set, and ignoresself.content_type
if it matches the content-type inferred from the file extension.See also
-
_L
= TypeVar(_L, bound=License)¶ Type:
TypeVar
Invariant
TypeVar
bound topyproject_parser.classes.License
.
-
_R
= TypeVar(_R, bound=Readme)¶ Type:
TypeVar
Invariant
TypeVar
bound topyproject_parser.classes.Readme
.