Skip to content

Commit a243628

Browse files
author
gward
committed
Added collapse_ws option.
git-svn-id: http://svn.python.org/projects/python/trunk@12863 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 4df97a9 commit a243628

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/distutils/text_file.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TextFile:
2323
'join_lines': 0,
2424
'lstrip_ws': 0,
2525
'rstrip_ws': 1,
26+
'collapse_ws': 0,
2627
}
2728

2829
def __init__ (self, filename=None, **options):
@@ -137,6 +138,10 @@ def readline (self):
137138
buildup_line = line[0:-2] + '\n'
138139
continue
139140

141+
# collapse internal whitespace (*after* joining lines!)
142+
if self.collapse_ws:
143+
line = re.sub (r'(\S)\s+(\S)', r'\1 \2', line)
144+
140145
# well, I guess there's some actual content there: return it
141146
return line
142147

0 commit comments

Comments
 (0)