[Python-checkins] r68223 - in python/branches/py3k: Doc/Makefile Doc/library/decimal.rst Doc/tools/rstlint.py
georg.brandl
python-checkins at python.org
Sat Jan 3 22:15:21 CET 2009
Author: georg.brandl
Date: Sat Jan 3 22:15:20 2009
New Revision: 68223
Log:
Merged revisions 68214-68215,68217-68218 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68214 | georg.brandl | 2009年01月03日 20:44:48 +0100 (2009年1月03日) | 2 lines
Make indentation consistent.
........
r68215 | georg.brandl | 2009年01月03日 21:15:14 +0100 (2009年1月03日) | 2 lines
Fix role name.
........
r68217 | georg.brandl | 2009年01月03日 21:30:15 +0100 (2009年1月03日) | 2 lines
Add rstlint, a little tool to find subtle markup problems and inconsistencies in the Doc sources.
........
r68218 | georg.brandl | 2009年01月03日 21:38:59 +0100 (2009年1月03日) | 2 lines
Recognize usage of the default role.
........
Added:
python/branches/py3k/Doc/tools/rstlint.py
- copied, changed from r68218, /python/trunk/Doc/tools/rstlint.py
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Doc/Makefile
python/branches/py3k/Doc/library/decimal.rst
Modified: python/branches/py3k/Doc/Makefile
==============================================================================
--- python/branches/py3k/Doc/Makefile (original)
+++ python/branches/py3k/Doc/Makefile Sat Jan 3 22:15:20 2009
@@ -14,7 +14,7 @@
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
$(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
-.PHONY: help checkout update build html htmlhelp clean coverage dist
+.PHONY: help checkout update build html htmlhelp clean coverage dist check
help:
@echo "Please use \`make <target>' where <target> is one of"
@@ -141,3 +141,5 @@
cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
+check:
+ $(PYTHON) tools/rstlint.py -i tools -s 2
Modified: python/branches/py3k/Doc/library/decimal.rst
==============================================================================
--- python/branches/py3k/Doc/library/decimal.rst (original)
+++ python/branches/py3k/Doc/library/decimal.rst Sat Jan 3 22:15:20 2009
@@ -474,7 +474,7 @@
>>> Decimal.from_float(float('-inf'))
Decimal('-Infinity')
- .. versionadded:: 2.7
+ .. versionadded:: 3.1
.. method:: fma(other, third[, context])
@@ -933,25 +933,25 @@
If the argument is a string, no leading or trailing whitespace is
permitted.
-.. method:: create_decimal_from_float(f)
+ .. method:: create_decimal_from_float(f)
Creates a new Decimal instance from a float *f* but rounding using *self*
- as the context. Unlike the :method:`Decimal.from_float` class method,
+ as the context. Unlike the :meth:`Decimal.from_float` class method,
the context precision, rounding method, flags, and traps are applied to
the conversion.
.. doctest::
- >>> context = Context(prec=5, rounding=ROUND_DOWN)
- >>> context.create_decimal_from_float(math.pi)
- Decimal('3.1415')
- >>> context = Context(prec=5, traps=[Inexact])
- >>> context.create_decimal_from_float(math.pi)
- Traceback (most recent call last):
- ...
- decimal.Inexact: None
+ >>> context = Context(prec=5, rounding=ROUND_DOWN)
+ >>> context.create_decimal_from_float(math.pi)
+ Decimal('3.1415')
+ >>> context = Context(prec=5, traps=[Inexact])
+ >>> context.create_decimal_from_float(math.pi)
+ Traceback (most recent call last):
+ ...
+ decimal.Inexact: None
- .. versionadded:: 2.7
+ .. versionadded:: 3.1
.. method:: Etiny()
Copied: python/branches/py3k/Doc/tools/rstlint.py (from r68218, /python/trunk/Doc/tools/rstlint.py)
==============================================================================
--- /python/trunk/Doc/tools/rstlint.py (original)
+++ python/branches/py3k/Doc/tools/rstlint.py Sat Jan 3 22:15:20 2009
@@ -69,7 +69,7 @@
yield 0, '\\r in code file'
code = code.replace('\r', '')
compile(code, fn, 'exec')
- except SyntaxError, err:
+ except SyntaxError as err:
yield err.lineno, 'not compilable: %s' % err
@@ -131,7 +131,7 @@
try:
gopts, args = getopt.getopt(argv[1:], 'vfs:i:')
except getopt.GetoptError:
- print usage
+ print(usage)
return 2
verbose = False
@@ -153,11 +153,11 @@
elif len(args) == 1:
path = args[0]
else:
- print usage
+ print(usage)
return 2
if not exists(path):
- print 'Error: path %s does not exist' % path
+ print('Error: path %s does not exist' % path)
return 2
count = defaultdict(int)
@@ -188,13 +188,13 @@
continue
if verbose:
- print 'Checking %s...' % fn
+ print('Checking %s...' % fn)
try:
with open(fn, 'r') as f:
lines = list(f)
- except (IOError, OSError), err:
- print '%s: cannot open: %s' % (fn, err)
+ except (IOError, OSError) as err:
+ print('%s: cannot open: %s' % (fn, err))
count[4] += 1
continue
@@ -204,20 +204,21 @@
csev = checker.severity
if csev >= severity:
for lno, msg in checker(fn, lines):
- print >>out, '[%d] %s:%d: %s' % (csev, fn, lno, msg)
+ print('[%d] %s:%d: %s' % (csev, fn, lno, msg),
+ file=out)
count[csev] += 1
if verbose:
- print
+ print()
if not count:
if severity > 1:
- print 'No problems with severity >= %d found.' % severity
+ print('No problems with severity >= %d found.' % severity)
else:
- print 'No problems found.'
+ print('No problems found.')
else:
for severity in sorted(count):
number = count[severity]
- print '%d problem%s with severity %d found.' % \
- (number, number > 1 and 's' or '', severity)
+ print('%d problem%s with severity %d found.' %
+ (number, number > 1 and 's' or '', severity))
return int(bool(count))
More information about the Python-checkins
mailing list