mirror of
https://github.com/python/cpython.git
synced 2025-11-10 18:42:04 +00:00
Added collapse_ws option.
This commit is contained in:
parent
a4e6ae6667
commit
db75afe6e5
1 changed files with 5 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ class TextFile:
|
||||||
'join_lines': 0,
|
'join_lines': 0,
|
||||||
'lstrip_ws': 0,
|
'lstrip_ws': 0,
|
||||||
'rstrip_ws': 1,
|
'rstrip_ws': 1,
|
||||||
|
'collapse_ws': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__ (self, filename=None, **options):
|
def __init__ (self, filename=None, **options):
|
||||||
|
|
@ -137,6 +138,10 @@ def readline (self):
|
||||||
buildup_line = line[0:-2] + '\n'
|
buildup_line = line[0:-2] + '\n'
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# collapse internal whitespace (*after* joining lines!)
|
||||||
|
if self.collapse_ws:
|
||||||
|
line = re.sub (r'(\S)\s+(\S)', r'\1 \2', line)
|
||||||
|
|
||||||
# well, I guess there's some actual content there: return it
|
# well, I guess there's some actual content there: return it
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue