You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
5.2 KiB

Merged revisions 70912,70944,70968,71033,71041,71208,71263,71286,71395-71396,71405-71406,71485,71492,71494 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70912 | georg.brandl | 2009-03-31 17:35:46 -0500 (Tue, 31 Mar 2009) | 1 line #5617: add a handy function to print a unicode string to gdbinit. ........ r70944 | georg.brandl | 2009-03-31 23:32:39 -0500 (Tue, 31 Mar 2009) | 1 line #5631: add upload to list of possible commands, which is presented in --help-commands. ........ r70968 | michael.foord | 2009-04-01 13:25:38 -0500 (Wed, 01 Apr 2009) | 1 line Adding Wing project file ........ r71033 | brett.cannon | 2009-04-01 22:34:53 -0500 (Wed, 01 Apr 2009) | 3 lines Fix two issues introduced by issue #71031 by changing the signature of PyImport_AppendInittab() to take a const char *. ........ r71041 | jesse.noller | 2009-04-02 00:17:26 -0500 (Thu, 02 Apr 2009) | 1 line Add custom initializer argument to multiprocess.Manager*, courtesy of lekma ........ r71208 | michael.foord | 2009-04-04 20:15:01 -0500 (Sat, 04 Apr 2009) | 4 lines Change the way unittest.TestSuite use their tests to always access them through iteration. Non behavior changing, this allows you to create custom subclasses that override __iter__. Issue #5693 ........ r71263 | michael.foord | 2009-04-05 14:19:28 -0500 (Sun, 05 Apr 2009) | 4 lines Adding assertIs and assertIsNot methods to unittest.TestCase Issue #2578 ........ r71286 | tarek.ziade | 2009-04-05 17:04:38 -0500 (Sun, 05 Apr 2009) | 1 line added a simplest test to distutils.spawn._nt_quote_args ........ r71395 | benjamin.peterson | 2009-04-08 08:27:29 -0500 (Wed, 08 Apr 2009) | 1 line these must be installed to correctly run tests ........ r71396 | benjamin.peterson | 2009-04-08 08:29:41 -0500 (Wed, 08 Apr 2009) | 1 line fix syntax ........ r71405 | andrew.kuchling | 2009-04-09 06:22:47 -0500 (Thu, 09 Apr 2009) | 1 line Add items ........ r71406 | andrew.kuchling | 2009-04-09 06:23:36 -0500 (Thu, 09 Apr 2009) | 1 line Typo fixes ........ r71485 | andrew.kuchling | 2009-04-11 11:12:23 -0500 (Sat, 11 Apr 2009) | 1 line Add various items ........ r71492 | georg.brandl | 2009-04-11 13:19:27 -0500 (Sat, 11 Apr 2009) | 1 line Take credit for a patch of mine. ........ r71494 | benjamin.peterson | 2009-04-11 14:31:00 -0500 (Sat, 11 Apr 2009) | 1 line ignore py3_test_grammar when compiling the library ........
17 years ago
Merged revisions 75149,75260-75263,75265-75267,75292,75300,75376,75405,75429-75433,75437,75445,75501,75551,75572,75589-75591,75657,75742,75868,75952-75957,76057,76105,76139,76143,76162,76223 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r75149 | gregory.p.smith | 2009-09-29 16:56:31 -0500 (Tue, 29 Sep 2009) | 3 lines Mention issue6972 in extractall docs about overwriting things outside of the supplied path. ........ r75260 | andrew.kuchling | 2009-10-05 16:24:20 -0500 (Mon, 05 Oct 2009) | 1 line Wording fix ........ r75261 | andrew.kuchling | 2009-10-05 16:24:35 -0500 (Mon, 05 Oct 2009) | 1 line Fix narkup ........ r75262 | andrew.kuchling | 2009-10-05 16:25:03 -0500 (Mon, 05 Oct 2009) | 1 line Document 'skip' parameter to constructor ........ r75263 | andrew.kuchling | 2009-10-05 16:25:35 -0500 (Mon, 05 Oct 2009) | 1 line Note side benefit of socket.create_connection() ........ r75265 | andrew.kuchling | 2009-10-05 17:31:11 -0500 (Mon, 05 Oct 2009) | 1 line Reword sentence ........ r75266 | andrew.kuchling | 2009-10-05 17:32:48 -0500 (Mon, 05 Oct 2009) | 1 line Use standard comma punctuation; reword some sentences in the docs ........ r75267 | andrew.kuchling | 2009-10-05 17:42:56 -0500 (Mon, 05 Oct 2009) | 1 line Backport r73983: Document the thousands separator. ........ r75292 | benjamin.peterson | 2009-10-08 22:11:36 -0500 (Thu, 08 Oct 2009) | 1 line death to old CVS keyword ........ r75300 | benjamin.peterson | 2009-10-09 16:48:14 -0500 (Fri, 09 Oct 2009) | 1 line fix some coding style ........ r75376 | benjamin.peterson | 2009-10-11 20:26:07 -0500 (Sun, 11 Oct 2009) | 1 line platform we don't care about ........ r75405 | neil.schemenauer | 2009-10-14 12:17:14 -0500 (Wed, 14 Oct 2009) | 4 lines Issue #1754094: Improve the stack depth calculation in the compiler. There should be no other effect than a small decrease in memory use. Patch by Christopher Tur Lesniewski-Laas. ........ r75429 | benjamin.peterson | 2009-10-14 20:47:28 -0500 (Wed, 14 Oct 2009) | 1 line pep8ify if blocks ........ r75430 | benjamin.peterson | 2009-10-14 20:49:37 -0500 (Wed, 14 Oct 2009) | 1 line use floor division and add a test that exercises the tabsize codepath ........ r75431 | benjamin.peterson | 2009-10-14 20:56:25 -0500 (Wed, 14 Oct 2009) | 1 line change test to what I intended ........ r75432 | benjamin.peterson | 2009-10-14 22:05:39 -0500 (Wed, 14 Oct 2009) | 1 line some cleanups ........ r75433 | benjamin.peterson | 2009-10-14 22:06:55 -0500 (Wed, 14 Oct 2009) | 1 line make inspect.isabstract() always return a boolean; add a test for it, too #7069 ........ r75437 | benjamin.peterson | 2009-10-15 10:44:46 -0500 (Thu, 15 Oct 2009) | 1 line only clear a module's __dict__ if the module is the only one with a reference to it #7140 ........ r75445 | vinay.sajip | 2009-10-16 09:06:44 -0500 (Fri, 16 Oct 2009) | 1 line Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. ........ r75501 | antoine.pitrou | 2009-10-18 13:37:11 -0500 (Sun, 18 Oct 2009) | 3 lines Add a comment about unreachable code, and fix a typo ........ r75551 | benjamin.peterson | 2009-10-19 22:14:10 -0500 (Mon, 19 Oct 2009) | 1 line use property api ........ r75572 | benjamin.peterson | 2009-10-20 16:55:17 -0500 (Tue, 20 Oct 2009) | 1 line clarify buffer arg #7178 ........ r75589 | benjamin.peterson | 2009-10-21 21:26:47 -0500 (Wed, 21 Oct 2009) | 1 line whitespace ........ r75590 | benjamin.peterson | 2009-10-21 21:36:47 -0500 (Wed, 21 Oct 2009) | 1 line rewrite to be nice to other implementations ........ r75591 | benjamin.peterson | 2009-10-21 21:50:38 -0500 (Wed, 21 Oct 2009) | 4 lines rewrite for style, clarify, and comments Also, use the hasattr() like scheme of allowing BaseException exceptions through. ........ r75657 | antoine.pitrou | 2009-10-24 07:41:27 -0500 (Sat, 24 Oct 2009) | 3 lines Fix compilation error in debug mode. ........ r75742 | benjamin.peterson | 2009-10-26 17:51:16 -0500 (Mon, 26 Oct 2009) | 1 line use 'is' instead of id() ........ r75868 | benjamin.peterson | 2009-10-27 15:59:18 -0500 (Tue, 27 Oct 2009) | 1 line test expect base classes ........ r75952 | georg.brandl | 2009-10-29 15:38:32 -0500 (Thu, 29 Oct 2009) | 1 line Use the correct function name in docstring. ........ r75953 | georg.brandl | 2009-10-29 15:39:50 -0500 (Thu, 29 Oct 2009) | 1 line Remove mention of the old -X command line switch. ........ r75954 | georg.brandl | 2009-10-29 15:53:00 -0500 (Thu, 29 Oct 2009) | 1 line Use constants instead of magic integers for test result. Do not re-run with --verbose3 for environment changing tests. ........ r75955 | georg.brandl | 2009-10-29 15:54:03 -0500 (Thu, 29 Oct 2009) | 1 line Use a single style for all the docstrings in the math module. ........ r75956 | georg.brandl | 2009-10-29 16:16:34 -0500 (Thu, 29 Oct 2009) | 1 line I do not think the "railroad" program mentioned is still available. ........ r75957 | georg.brandl | 2009-10-29 16:44:56 -0500 (Thu, 29 Oct 2009) | 1 line Fix constant name. ........ r76057 | benjamin.peterson | 2009-11-02 09:06:45 -0600 (Mon, 02 Nov 2009) | 1 line prevent a rather unlikely segfault ........ r76105 | georg.brandl | 2009-11-04 01:38:12 -0600 (Wed, 04 Nov 2009) | 1 line #7259: show correct equivalent for operator.i* operations in docstring; fix minor issues in operator docs. ........ r76139 | benjamin.peterson | 2009-11-06 19:04:38 -0600 (Fri, 06 Nov 2009) | 1 line spelling ........ r76143 | georg.brandl | 2009-11-07 02:26:07 -0600 (Sat, 07 Nov 2009) | 1 line #7271: fix typo. ........ r76162 | benjamin.peterson | 2009-11-08 22:10:53 -0600 (Sun, 08 Nov 2009) | 1 line discuss how to use -p ........ r76223 | georg.brandl | 2009-11-12 02:29:46 -0600 (Thu, 12 Nov 2009) | 1 line Give the profile module a module directive. ........
17 years ago
  1. """distutils.command.check
  2. Implements the Distutils 'check' command.
  3. """
  4. __revision__ = "$Id$"
  5. from distutils.core import Command
  6. from distutils.errors import DistutilsSetupError
  7. try:
  8. # docutils is installed
  9. from docutils.utils import Reporter
  10. from docutils.parsers.rst import Parser
  11. from docutils import frontend
  12. from docutils import nodes
  13. from io import StringIO
  14. class SilentReporter(Reporter):
  15. def __init__(self, source, report_level, halt_level, stream=None,
  16. debug=0, encoding='ascii', error_handler='replace'):
  17. self.messages = []
  18. Reporter.__init__(self, source, report_level, halt_level, stream,
  19. debug, encoding, error_handler)
  20. def system_message(self, level, message, *children, **kwargs):
  21. self.messages.append((level, message, children, kwargs))
  22. HAS_DOCUTILS = True
  23. except Exception:
  24. # Catch all exceptions because exceptions besides ImportError probably
  25. # indicate that docutils is not ported to Py3k.
  26. HAS_DOCUTILS = False
  27. class check(Command):
  28. """This command checks the meta-data of the package.
  29. """
  30. description = ("perform some checks on the package")
  31. user_options = [('metadata', 'm', 'Verify meta-data'),
  32. ('restructuredtext', 'r',
  33. ('Checks if long string meta-data syntax '
  34. 'are reStructuredText-compliant')),
  35. ('strict', 's',
  36. 'Will exit with an error if a check fails')]
  37. boolean_options = ['metadata', 'restructuredtext', 'strict']
  38. def initialize_options(self):
  39. """Sets default values for options."""
  40. self.restructuredtext = 0
  41. self.metadata = 1
  42. self.strict = 0
  43. self._warnings = 0
  44. def finalize_options(self):
  45. pass
  46. def warn(self, msg):
  47. """Counts the number of warnings that occurs."""
  48. self._warnings += 1
  49. return Command.warn(self, msg)
  50. def run(self):
  51. """Runs the command."""
  52. # perform the various tests
  53. if self.metadata:
  54. self.check_metadata()
  55. if self.restructuredtext:
  56. if HAS_DOCUTILS:
  57. self.check_restructuredtext()
  58. elif self.strict:
  59. raise DistutilsSetupError('The docutils package is needed.')
  60. # let's raise an error in strict mode, if we have at least
  61. # one warning
  62. if self.strict and self._warnings > 0:
  63. raise DistutilsSetupError('Please correct your package.')
  64. def check_metadata(self):
  65. """Ensures that all required elements of meta-data are supplied.
  66. name, version, URL, (author and author_email) or
  67. (maintainer and maintainer_email)).
  68. Warns if any are missing.
  69. """
  70. metadata = self.distribution.metadata
  71. missing = []
  72. for attr in ('name', 'version', 'url'):
  73. if not (hasattr(metadata, attr) and getattr(metadata, attr)):
  74. missing.append(attr)
  75. if missing:
  76. self.warn("missing required meta-data: %s" % ', '.join(missing))
  77. if metadata.author:
  78. if not metadata.author_email:
  79. self.warn("missing meta-data: if 'author' supplied, " +
  80. "'author_email' must be supplied too")
  81. elif metadata.maintainer:
  82. if not metadata.maintainer_email:
  83. self.warn("missing meta-data: if 'maintainer' supplied, " +
  84. "'maintainer_email' must be supplied too")
  85. else:
  86. self.warn("missing meta-data: either (author and author_email) " +
  87. "or (maintainer and maintainer_email) " +
  88. "must be supplied")
  89. def check_restructuredtext(self):
  90. """Checks if the long string fields are reST-compliant."""
  91. data = self.distribution.get_long_description()
  92. for warning in self._check_rst_data(data):
  93. line = warning[-1].get('line')
  94. if line is None:
  95. warning = warning[1]
  96. else:
  97. warning = '%s (line %s)' % (warning[1], line)
  98. self.warn(warning)
  99. def _check_rst_data(self, data):
  100. """Returns warnings when the provided data doesn't compile."""
  101. source_path = StringIO()
  102. parser = Parser()
  103. settings = frontend.OptionParser().get_default_values()
  104. settings.tab_width = 4
  105. settings.pep_references = None
  106. settings.rfc_references = None
  107. reporter = SilentReporter(source_path,
  108. settings.report_level,
  109. settings.halt_level,
  110. stream=settings.warning_stream,
  111. debug=settings.debug,
  112. encoding=settings.error_encoding,
  113. error_handler=settings.error_encoding_error_handler)
  114. document = nodes.document(settings, reporter, source=source_path)
  115. document.note_source(source_path, -1)
  116. try:
  117. parser.parse(data, document)
  118. except AttributeError:
  119. reporter.messages.append((-1, 'Could not finish the parsing.',
  120. '', {}))
  121. return reporter.messages