Changeset 391 for python/trunk/Lib/textwrap.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/textwrap.py
r2 r391 6 6 # Written by Greg Ward <gward@python.net> 7 7 8 __revision__ = "$Id : textwrap.py 68135 2009-01-01 15:46:10Z georg.brandl$"8 __revision__ = "$Id$" 9 9 10 10 import string, re 11 12 try: 13 _unicode = unicode 14 except NameError: 15 # If Python is built without Unicode support, the unicode type 16 # will not exist. Fake one. 17 class _unicode(object): 18 pass 11 19 12 20 # Do the right thing with boolean values for all known Python versions … … 148 156 if isinstance(text, str): 149 157 text = text.translate(self.whitespace_trans) 150 elif isinstance(text, unicode):158 elif isinstance(text, _unicode): 151 159 text = text.translate(self.unicode_whitespace_trans) 152 160 return text … … 157 165 158 166 Split the text to wrap into indivisible chunks. Chunks are 159 not quite the same as words; see wrap_chunks() for full167 not quite the same as words; see _wrap_chunks() for full 160 168 details. As an example, the text 161 169 Look, goof-ball -- use the -b option! … … 168 176 otherwise. 169 177 """ 170 if isinstance(text, unicode):178 if isinstance(text, _unicode): 171 179 if self.break_on_hyphens: 172 180 pat = self.wordsep_re_uni … … 192 200 """ 193 201 i = 0 194 pat = self.sentence_end_re202 patsearch = self.sentence_end_re.search 195 203 while i < len(chunks)-1: 196 if chunks[i+1] == " " and pat .search(chunks[i]):204 if chunks[i+1] == " " and patsearch(chunks[i]): 197 205 chunks[i+1] = " " 198 206 i += 2
Note:
See TracChangeset
for help on using the changeset viewer.