]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/command/check.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / distutils / command / check.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/command/check.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/command/check.py
deleted file mode 100644 (file)
index bfef779..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-"""distutils.command.check\r
-\r
-Implements the Distutils 'check' command.\r
-"""\r
-__revision__ = "$Id$"\r
-\r
-from distutils.core import Command\r
-from distutils.errors import DistutilsSetupError\r
-\r
-try:\r
-    # docutils is installed\r
-    from docutils.utils import Reporter\r
-    from docutils.parsers.rst import Parser\r
-    from docutils import frontend\r
-    from docutils import nodes\r
-    from StringIO import StringIO\r
-\r
-    class SilentReporter(Reporter):\r
-\r
-        def __init__(self, source, report_level, halt_level, stream=None,\r
-                     debug=0, encoding='ascii', error_handler='replace'):\r
-            self.messages = []\r
-            Reporter.__init__(self, source, report_level, halt_level, stream,\r
-                              debug, encoding, error_handler)\r
-\r
-        def system_message(self, level, message, *children, **kwargs):\r
-            self.messages.append((level, message, children, kwargs))\r
-\r
-    HAS_DOCUTILS = True\r
-except ImportError:\r
-    # docutils is not installed\r
-    HAS_DOCUTILS = False\r
-\r
-class check(Command):\r
-    """This command checks the meta-data of the package.\r
-    """\r
-    description = ("perform some checks on the package")\r
-    user_options = [('metadata', 'm', 'Verify meta-data'),\r
-                    ('restructuredtext', 'r',\r
-                     ('Checks if long string meta-data syntax '\r
-                      'are reStructuredText-compliant')),\r
-                    ('strict', 's',\r
-                     'Will exit with an error if a check fails')]\r
-\r
-    boolean_options = ['metadata', 'restructuredtext', 'strict']\r
-\r
-    def initialize_options(self):\r
-        """Sets default values for options."""\r
-        self.restructuredtext = 0\r
-        self.metadata = 1\r
-        self.strict = 0\r
-        self._warnings = 0\r
-\r
-    def finalize_options(self):\r
-        pass\r
-\r
-    def warn(self, msg):\r
-        """Counts the number of warnings that occurs."""\r
-        self._warnings += 1\r
-        return Command.warn(self, msg)\r
-\r
-    def run(self):\r
-        """Runs the command."""\r
-        # perform the various tests\r
-        if self.metadata:\r
-            self.check_metadata()\r
-        if self.restructuredtext:\r
-            if HAS_DOCUTILS:\r
-                self.check_restructuredtext()\r
-            elif self.strict:\r
-                raise DistutilsSetupError('The docutils package is needed.')\r
-\r
-        # let's raise an error in strict mode, if we have at least\r
-        # one warning\r
-        if self.strict and self._warnings > 0:\r
-            raise DistutilsSetupError('Please correct your package.')\r
-\r
-    def check_metadata(self):\r
-        """Ensures that all required elements of meta-data are supplied.\r
-\r
-        name, version, URL, (author and author_email) or\r
-        (maintainer and maintainer_email)).\r
-\r
-        Warns if any are missing.\r
-        """\r
-        metadata = self.distribution.metadata\r
-\r
-        missing = []\r
-        for attr in ('name', 'version', 'url'):\r
-            if not (hasattr(metadata, attr) and getattr(metadata, attr)):\r
-                missing.append(attr)\r
-\r
-        if missing:\r
-            self.warn("missing required meta-data: %s"  % ', '.join(missing))\r
-        if metadata.author:\r
-            if not metadata.author_email:\r
-                self.warn("missing meta-data: if 'author' supplied, " +\r
-                          "'author_email' must be supplied too")\r
-        elif metadata.maintainer:\r
-            if not metadata.maintainer_email:\r
-                self.warn("missing meta-data: if 'maintainer' supplied, " +\r
-                          "'maintainer_email' must be supplied too")\r
-        else:\r
-            self.warn("missing meta-data: either (author and author_email) " +\r
-                      "or (maintainer and maintainer_email) " +\r
-                      "must be supplied")\r
-\r
-    def check_restructuredtext(self):\r
-        """Checks if the long string fields are reST-compliant."""\r
-        data = self.distribution.get_long_description()\r
-        for warning in self._check_rst_data(data):\r
-            line = warning[-1].get('line')\r
-            if line is None:\r
-                warning = warning[1]\r
-            else:\r
-                warning = '%s (line %s)' % (warning[1], line)\r
-            self.warn(warning)\r
-\r
-    def _check_rst_data(self, data):\r
-        """Returns warnings when the provided data doesn't compile."""\r
-        source_path = StringIO()\r
-        parser = Parser()\r
-        settings = frontend.OptionParser().get_default_values()\r
-        settings.tab_width = 4\r
-        settings.pep_references = None\r
-        settings.rfc_references = None\r
-        reporter = SilentReporter(source_path,\r
-                          settings.report_level,\r
-                          settings.halt_level,\r
-                          stream=settings.warning_stream,\r
-                          debug=settings.debug,\r
-                          encoding=settings.error_encoding,\r
-                          error_handler=settings.error_encoding_error_handler)\r
-\r
-        document = nodes.document(settings, reporter, source=source_path)\r
-        document.note_source(source_path, -1)\r
-        try:\r
-            parser.parse(data, document)\r
-        except AttributeError:\r
-            reporter.messages.append((-1, 'Could not finish the parsing.',\r
-                                      '', {}))\r
-\r
-        return reporter.messages\r