Added despace.py for removing excessive blank lines
authorW. Trevor King <wking@drexel.edu>
Wed, 21 Jul 2010 11:48:49 +0000 (07:48 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 21 Jul 2010 11:48:49 +0000 (07:48 -0400)
misc/despace.py [new file with mode: 0644]

diff --git a/misc/despace.py b/misc/despace.py
new file mode 100644 (file)
index 0000000..b7b6522
--- /dev/null
@@ -0,0 +1,12 @@
+import sys
+
+consecutive_blanks = 0
+for line in sys.stdin.readlines():
+    line = line.rstrip()
+    if len(line) == 0:
+        consecutive_blanks += 1
+        if consecutive_blanks <= 3:
+            print line
+    else:
+        consecutive_blanks = 0
+        print line