pyproject_parser.utils¶
Utility functions.
Exceptions:
Warning for the use of deprecated features in pyproject.toml. |
Functions:
|
Return the inferred content type for the given (readme) filename. |
|
Join an iterable of strings with newlines, and indent each line with a tab if there is more then one element. |
|
Adds |
|
Attempt to render the given content as Markdown. |
|
Attempt to render the given content as ReStructuredText. |
-
exception
PyProjectDeprecationWarning[source]¶ Bases:
WarningWarning for the use of deprecated features in pyproject.toml.
This is a user-facing warning which will be shown by default. For developer-facing warnings intended for direct consumers of this library, use a standard
DeprecationWarning.New in version 0.5.0.
-
content_type_from_filename(filename)[source]¶ Return the inferred content type for the given (readme) filename.
-
indent_join(iterable)[source]¶ Join an iterable of strings with newlines, and indent each line with a tab if there is more then one element.
New in version 0.14.0.
-
indent_with_tab(text, depth=1, predicate=None)[source]¶ Adds
'\t'to the beginning of selected lines in ‘text’.- Parameters
text (
str) – The text to indent.depth (
int) – The depth of the indentation. Default1.predicate (
Optional[Callable[[str],bool]]) – If given,'\t'will only be added to the lines wherepredicate(line)is :py:obj`True`. Ifpredicateis not provided, it will default to adding'\t'to all non-empty lines that do not consist solely of whitespace characters. DefaultNone.
- Return type
New in version 0.14.0.
-
render_markdown(content)[source]¶ Attempt to render the given content as Markdown.
Attention
This function has the following additional requirements:
docutils<0.22,>=0.16 readme-renderer[md]>=27.0
These can be installed as follows:
python -m pip install pyproject-parser[readme]- Parameters
content (
str)
-
render_rst(content, filename='<string>')[source]¶ Attempt to render the given content as ReStructuredText.
Attention
This function has the following additional requirements:
docutils<0.22,>=0.16 readme-renderer[md]>=27.0
These can be installed as follows:
python -m pip install pyproject-parser[readme]- Parameters
Changed in version 0.8.0: Added the
filenameargument.