]> granicus.if.org Git - python/commitdiff
Added collapse_ws option.
authorGreg Ward <gward@python.net>
Mon, 8 Mar 1999 21:46:11 +0000 (21:46 +0000)
committerGreg Ward <gward@python.net>
Mon, 8 Mar 1999 21:46:11 +0000 (21:46 +0000)
Lib/distutils/text_file.py

index 9e1a73b79890c532c1984356e56db6a4695e2461..eab498d76c0924ae8f01f6ea39e2daa1e531f496 100644 (file)
@@ -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