Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Side by Side Diff: Lib/textwrap.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt ('k') | Lib/threading.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Text wrapping and filling. 1 """Text wrapping and filling.
2 """ 2 """
3 3
4 # Copyright (C) 1999-2001 Gregory P. Ward. 4 # Copyright (C) 1999-2001 Gregory P. Ward.
5 # Copyright (C) 2002, 2003 Python Software Foundation. 5 # Copyright (C) 2002, 2003 Python Software Foundation.
6 # Written by Greg Ward <gward@python.net> 6 # Written by Greg Ward <gward@python.net>
7 7
8 __revision__ = "$Id$" 8 __revision__ = "$Id$"
9 9
10 import re 10 import string, re
11 11
12 __all__ = ['TextWrapper', 'wrap', 'fill', 'dedent'] 12 __all__ = ['TextWrapper', 'wrap', 'fill', 'dedent']
13 13
14 # Hardcode the recognized whitespace characters to the US-ASCII 14 # Hardcode the recognized whitespace characters to the US-ASCII
15 # whitespace characters. The main reason for doing this is that in 15 # whitespace characters. The main reason for doing this is that in
16 # ISO-8859-1, 0xa0 is non-breaking whitespace, so in certain locales 16 # ISO-8859-1, 0xa0 is non-breaking whitespace, so in certain locales
17 # that character winds up in string.whitespace. Respecting 17 # that character winds up in string.whitespace. Respecting
18 # string.whitespace in those cases would 1) make textwrap treat 0xa0 the 18 # string.whitespace in those cases would 1) make textwrap treat 0xa0 the
19 # same as any other whitespace char, which is clearly wrong (it's a 19 # same as any other whitespace char, which is clearly wrong (it's a
20 # *non-breaking* space), 2) possibly cause problems with Unicode, 20 # *non-breaking* space), 2) possibly cause problems with Unicode,
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 "line = %r, margin = %r" % (line, margin) 380 "line = %r, margin = %r" % (line, margin)
381 381
382 if margin: 382 if margin:
383 text = re.sub(r'(?m)^' + margin, '', text) 383 text = re.sub(r'(?m)^' + margin, '', text)
384 return text 384 return text
385 385
386 if __name__ == "__main__": 386 if __name__ == "__main__":
387 #print dedent("\tfoo\n\tbar") 387 #print dedent("\tfoo\n\tbar")
388 #print dedent(" \thello there\n \t how are you?") 388 #print dedent(" \thello there\n \t how are you?")
389 print(dedent("Hello there.\n This is indented.")) 389 print(dedent("Hello there.\n This is indented."))
OLDNEW
« no previous file with comments | « Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt ('k') | Lib/threading.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+