# 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
# limitations under the License.
from __future__ import absolute_import, division, print_function





# Regular expression used to capture and reformat doctuils warnings into
# something that a human can understand. This is loosely borrowed from
# Sphinx: https://github.com/sphinx-doc/sphinx/blob
# /c35eb6fade7a3b4a6de4183d1dd4196f04a5edaf/sphinx/util/docutils.py#L199
_REPORT_RE = re.compile(
    r'^<string>:(?P<line>(?:\d+)?): '
    r'\((?P<level>DEBUG|INFO|WARNING|ERROR|SEVERE)/(\d+)?\) '
    r'(?P<message>.*)', re.DOTALL | re.MULTILINE)


class _WarningStream(object):
    def __init__(self):
        self.output = io.StringIO()

    def write(self, text):
        matched = _REPORT_RE.search(text)

        if not matched:
            self.output.write(text)
            return

        self.output.write(
            u"line {line}: {level_text}: {message}\n".format(

# 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

# limitations under the License.
from __future__ import absolute_import, division, print_function





# Regular expression used to capture and reformat doctuils warnings into
# something that a human can understand. This is loosely borrowed from
# Sphinx: https://github.com/sphinx-doc/sphinx/blob
# /c35eb6fade7a3b4a6de4183d1dd4196f04a5edaf/sphinx/util/docutils.py#L199
_REPORT_RE = re.compile(
    r'^<string>:(?P<line>(?:\d+)?): '
    r'\((?P<level>DEBUG|INFO|WARNING|ERROR|SEVERE)/(\d+)?\) '
    r'(?P<message>.*)', re.DOTALL | re.MULTILINE)


class _WarningStream(object):
    def __init__(self):
        self.output = io.StringIO()

    def write(self, text):
        matched = _REPORT_RE.search(text)

        if not matched:
            self.output.write(text)
            return

        self.output.write(
            u"line {line}: {level_text}: {message}\n".format(

                level_text=matched.group('level').capitalize(),