Example #1
0
    def check_restructuredtext(self):
        """
        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)

        if markup is None:
            self.warn(
                "The project's long_description has invalid markup which will "
                "not be rendered on PyPI. The following syntax errors were "
                "detected:\n%s" % stream)
            return

        self.announce(
            "The project's long description is valid RST.",
            level=distutils.log.INFO)
Example #2
0
 def warn(self, msg):
     """Counts the number of warnings that occurs."""
     self._warnings += 1
     return Command.warn(self, msg)
Example #3
0
 def warn(self, msg):
     """Counts the number of warnings that occurs."""
     self._warnings += 1
     return Command.warn(self, msg)
Example #4
0
 def warn(self, msg):
     self._warnings += 1
     return Command.warn(self, msg)