cpython: d38e821c1b80 (original) (raw)

Mercurial > cpython

changeset 77050:d38e821c1b80

#13152: Allow to specify a custom tabsize for expanding tabs in textwrap Patch by John Feuerstein. [#13152]

Hynek Schlawack hs@ox.cx
date Sat, 19 May 2012 13:33:11 +0200
parents 732d70746fc0
children b78c67665a7f
files Doc/library/textwrap.rst Lib/test/test_textwrap.py Lib/textwrap.py Misc/NEWS
diffstat 4 files changed, 29 insertions(+), 4 deletions(-)[+] [-] Doc/library/textwrap.rst 9 Lib/test/test_textwrap.py 8 Lib/textwrap.py 13 Misc/NEWS 3

line wrap: on

line diff

--- a/Doc/library/textwrap.rst +++ b/Doc/library/textwrap.rst @@ -107,6 +107,15 @@ indentation from strings that have unwan expanded to spaces using the :meth:expandtabs method of text.

+

+ + .. attribute:: replace_whitespace (default: True) If true, each whitespace character (as defined by

--- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -91,6 +91,14 @@ What a mess result = wrapper.fill(text) self.check(result, '\n'.join(expect))

+

+ def test_fix_sentence_endings(self): wrapper = TextWrapper(60, fix_sentence_endings=True)

--- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -39,8 +39,11 @@ class TextWrapper: of wrapped output; also counts towards each line's width. expand_tabs (default: true) Expand tabs in input text to spaces before further processing.

@@ -100,7 +103,8 @@ class TextWrapper: fix_sentence_endings=False, break_long_words=True, drop_whitespace=True,

@@ -110,6 +114,7 @@ class TextWrapper: self.break_long_words = break_long_words self.drop_whitespace = drop_whitespace self.break_on_hyphens = break_on_hyphens

# -- Private methods ----------------------------------------------- @@ -123,7 +128,7 @@ class TextWrapper: becomes " foo bar baz". """ if self.expand_tabs:

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -38,6 +38,9 @@ Core and Builtins Library ------- +- Issue #13152: Allow to specify a custom tabsize for expanding tabs in