|
From: <mi...@us...> - 2017-08-17 15:58:26
|
Revision: 8171
http://sourceforge.net/p/docutils/code/8171
Author: milde
Date: 2017-08-17 15:58:23 +0000 (Thu, 17 Aug 2017)
Log Message:
-----------
Small cleanup and formatting edits.
* Use `True` instead of 1 in boolean arguments.
* Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/utils/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/HISTORY.txt 2017-08-17 15:58:23 UTC (rev 8171)
@@ -28,8 +28,7 @@
* docutils/parsers/rst/directives/html.py:
- - [Fix for bug 281:] Allow backslash-escaped colons in meta directive
- field list field names (also updated docs/dev/todo.txt).
+ - Fix [ 281 ] Remove escaping backslashes in meta directive content.
* docutils/writers/latex2e/__init__.py
@@ -36,7 +35,11 @@
- Fix [ 323 ] don't add ``\phantomsection`` and whitespace to
``parts['title'].
+* docutils/utils/__init__.py:
+ - Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
+
+
Release 0.14 (2017-08-03)
=========================
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -37,7 +37,8 @@
{'component': 'writer',
'format': 'html',
'nodes': [node]})
- node['content'] = utils.unescape(utils.escape2null(' '.join(indented)))
+ node['content'] = utils.unescape(utils.escape2null(
+ ' '.join(indented)))
if not indented:
line = self.state_machine.line
msg = self.reporter.info(
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -308,7 +308,7 @@
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
set_classes(options)
- node = nodes.raw(rawtext, utils.unescape(text, 1), **options)
+ node = nodes.raw(rawtext, utils.unescape(text, True), **options)
node.source, node.line = inliner.reporter.get_source_and_line(lineno)
return [node], []
@@ -325,7 +325,7 @@
if language and language not in classes:
classes.append(language)
try:
- tokens = Lexer(utils.unescape(text, 1), language,
+ tokens = Lexer(utils.unescape(text, True), language,
inliner.document.settings.syntax_highlight)
except LexerError, error:
msg = inliner.reporter.warning(error)
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/parsers/rst/states.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -714,14 +714,14 @@
text = unescape(endmatch.string[:endmatch.start(1)],
restore_backslashes)
textend = matchend + endmatch.end(1)
- rawsource = unescape(string[matchstart:textend], 1)
+ rawsource = unescape(string[matchstart:textend], True)
return (string[:matchstart], [nodeclass(rawsource, text)],
string[textend:], [], endmatch.group(1))
msg = self.reporter.warning(
'Inline %s start-string without end-string.'
% nodeclass.__name__, line=lineno)
- text = unescape(string[matchstart:matchend], 1)
- rawsource = unescape(string[matchstart:matchend], 1)
+ text = unescape(string[matchstart:matchend], True)
+ rawsource = unescape(string[matchstart:matchend], True)
prb = self.problematic(text, rawsource, msg)
return string[:matchstart], [prb], string[matchend:], [msg], ''
@@ -764,25 +764,25 @@
'Multiple roles in interpreted text (both '
'prefix and suffix present; only one allowed).',
line=lineno)
- text = unescape(string[rolestart:textend], 1)
+ text = unescape(string[rolestart:textend], True)
prb = self.problematic(text, text, msg)
return string[:rolestart], [prb], string[textend:], [msg]
role = endmatch.group('suffix')[1:-1]
position = 'suffix'
escaped = endmatch.string[:endmatch.start(1)]
- rawsource = unescape(string[matchstart:textend], 1)
+ rawsource = unescape(string[matchstart:textend], True)
if rawsource[-1:] == '_':
if role:
msg = self.reporter.warning(
'Mismatch: both interpreted text role %s and '
'reference suffix.' % position, line=lineno)
- text = unescape(string[rolestart:textend], 1)
+ text = unescape(string[rolestart:textend], True)
prb = self.problematic(text, text, msg)
return string[:rolestart], [prb], string[textend:], [msg]
return self.phrase_ref(string[:matchstart], string[textend:],
rawsource, escaped, unescape(escaped))
else:
- rawsource = unescape(string[rolestart:textend], 1)
+ rawsource = unescape(string[rolestart:textend], True)
nodelist, messages = self.interpreted(rawsource, escaped, role,
lineno)
return (string[:rolestart], nodelist,
@@ -790,7 +790,7 @@
msg = self.reporter.warning(
'Inline interpreted text or phrase reference start-string '
'without end-string.', line=lineno)
- text = unescape(string[matchstart:matchend], 1)
+ text = unescape(string[matchstart:matchend], True)
prb = self.problematic(text, text, msg)
return string[:matchstart], [prb], string[matchend:], [msg]
@@ -977,8 +977,8 @@
else:
addscheme = ''
text = match.group('whole')
- unescaped = unescape(text, 0)
- return [nodes.reference(unescape(text, 1), unescaped,
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped,
refuri=addscheme + unescaped)]
else: # not a valid scheme
raise MarkupMismatch
@@ -993,8 +993,8 @@
raise MarkupMismatch
ref = (self.document.settings.pep_base_url
+ self.document.settings.pep_file_url_template % pepnum)
- unescaped = unescape(text, 0)
- return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)]
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
rfc_url = 'rfc%d.html'
@@ -1005,8 +1005,8 @@
ref = self.document.settings.rfc_base_url + self.rfc_url % rfcnum
else:
raise MarkupMismatch
- unescaped = unescape(text, 0)
- return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)]
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
def implicit_inline(self, text, lineno):
"""
@@ -1028,7 +1028,7 @@
self.implicit_inline(text[match.end():], lineno))
except MarkupMismatch:
pass
- return [nodes.Text(unescape(text), rawsource=unescape(text, 1))]
+ return [nodes.Text(unescape(text), rawsource=unescape(text, True))]
dispatch = {'*': emphasis,
'**': strong,
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/utils/__init__.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -660,15 +660,12 @@
r.append(item)
return r
-# by Li Daobing http://code.activestate.com/recipes/190465/
-# since Python 2.6 there is also itertools.combinations()
def unique_combinations(items, n):
- """Return n-length tuples, in sorted order, no repeated elements"""
- if n==0: yield []
- else:
- for i in xrange(len(items)-n+1):
- for cc in unique_combinations(items[i+1:],n-1):
- yield [items[i]]+cc
+ """Return `itertools.combinations`."""
+ warnings.warn('docutils.utils.unique_combinations is deprecated; '
+ 'use itertools.combinations directly.',
+ DeprecationWarning, stacklevel=2)
+ return itertools.combinations(items, n)
def normalize_language_tag(tag):
"""Return a list of normalized combinations for a `BCP 47` language tag.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|