diff options
author | Greg Ward <gward@python.net> | 1999-03-08 21:46:11 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 1999-03-08 21:46:11 (GMT) |
commit | db75afe6e5fbce9eede3ce5e7ec00510f53eda99 (patch) | |
tree | d11e7cf6af40350c2f2295544a00356d1f108688 /Lib/distutils | |
parent | a4e6ae666794966e0440f31c85461fb781525a10 (diff) | |
download | cpython-db75afe6e5fbce9eede3ce5e7ec00510f53eda99.zip cpython-db75afe6e5fbce9eede3ce5e7ec00510f53eda99.tar.gz cpython-db75afe6e5fbce9eede3ce5e7ec00510f53eda99.tar.bz2 |
Added collapse_ws option.
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/text_file.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py index 9e1a73b..eab498d 100644 --- a/Lib/distutils/text_file.py +++ b/Lib/distutils/text_file.py @@ -23,6 +23,7 @@ class TextFile: 'join_lines': 0, 'lstrip_ws': 0, 'rstrip_ws': 1, + 'collapse_ws': 0, } def __init__ (self, filename=None, **options): @@ -137,6 +138,10 @@ class TextFile: buildup_line = line[0:-2] + '\n' 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 return line |