# Path: readme_renderer/rst.py
# def render(raw, stream=None, **kwargs):
#     if stream is None:
#         # Use a io.StringIO as the warning stream to prevent warnings from
#         # being printed to sys.stderr.
#         stream = io.StringIO()
# 
#     settings = SETTINGS.copy()
#     settings["warning_stream"] = stream
# 
#     writer = Writer()
#     writer.translator_class = ReadMeHTMLTranslator
# 
#     try:
#         parts = publish_parts(raw, writer=writer, settings_overrides=settings)
#     except SystemMessage:
#         rendered = None
#     else:
#         rendered = parts.get("docinfo", "") + parts.get("fragment", "")
# 
#     if rendered:
#         return clean(rendered)
#     else:
#         return None


import cgi
import io
import re
import distutils.log
from distutils.command.check import check as _check
from distutils.core import Command
from ..rst import render
        Checks if the long string fields are reST-compliant.
        """
        # Warn that this command is deprecated
        # Don't use self.warn() because it will cause the check to fail.
        Command.warn(
            self,
            "This command has been deprecated. Use `twine check` instead: "
            "https://packaging.python.org/guides/making-a-pypi-friendly-readme"
            "#validating-restructuredtext-markup"
        )

        data = self.distribution.get_long_description()
        content_type = getattr(
            self.distribution.metadata, 'long_description_content_type', None)

        if content_type:
            content_type, _ = cgi.parse_header(content_type)
            if content_type != 'text/x-rst':
                self.warn(
                    "Not checking long description content type '%s', this "
                    "command only checks 'text/x-rst'." % content_type)
                return

        # None or empty string should both trigger this branch.
        if not data or data == 'UNKNOWN':
            self.warn(
                "The project's long_description is either missing or empty.")
            return

        stream = _WarningStream()

# Path: readme_renderer/rst.py
# def render(raw, stream=None, **kwargs):
#     if stream is None:
#         # Use a io.StringIO as the warning stream to prevent warnings from
#         # being printed to sys.stderr.
#         stream = io.StringIO()
# 
#     settings = SETTINGS.copy()
#     settings["warning_stream"] = stream
# 
#     writer = Writer()
#     writer.translator_class = ReadMeHTMLTranslator
# 
#     try:
#         parts = publish_parts(raw, writer=writer, settings_overrides=settings)
#     except SystemMessage:
#         rendered = None
#     else:
#         rendered = parts.get("docinfo", "") + parts.get("fragment", "")
# 
#     if rendered:
#         return clean(rendered)
#     else:
#         return None


# Path: readme_renderer/integration/distutils.py
import cgi
import io
import re
import distutils.log
from distutils.command.check import check as _check
from distutils.core import Command
from ..rst import render

        Checks if the long string fields are reST-compliant.
        """
        # Warn that this command is deprecated
        # Don't use self.warn() because it will cause the check to fail.
        Command.warn(
            self,
            "This command has been deprecated. Use `twine check` instead: "
            "https://packaging.python.org/guides/making-a-pypi-friendly-readme"
            "#validating-restructuredtext-markup"
        )

        data = self.distribution.get_long_description()
        content_type = getattr(
            self.distribution.metadata, 'long_description_content_type', None)

        if content_type:
            content_type, _ = cgi.parse_header(content_type)
            if content_type != 'text/x-rst':
                self.warn(
                    "Not checking long description content type '%s', this "
                    "command only checks 'text/x-rst'." % content_type)
                return

        # None or empty string should both trigger this branch.
        if not data or data == 'UNKNOWN':
            self.warn(
                "The project's long_description is either missing or empty.")
            return

        stream = _WarningStream()

        markup = render(data, stream=stream)