--- /dev/null
+#!/usr/bin/env python
+
+import os
+import sys
+import tempfile
+import re
+import shutil
+
+re_komma = re.compile(r',(\s*[\)\]\}])')
+
+i = 0
+for fname in sys.argv:
+ if i == 0:
+ i = 1
+ continue
+ if not os.path.exists(fname):
+ sys.stderr.write("Datei %r existiert nicht.\n" % (fname))
+ continue
+ (ofd, ofname) = tempfile.mkstemp()
+ print "Mangling %r -> %r" % (fname, ofname)
+ try:
+ try:
+ ifile = open(fname)
+ lines = ifile.read()
+ nlines = re_komma.sub(r'\1', lines)
+ os.write(ofd, nlines)
+ finally:
+ os.close(ofd)
+ ifile.close()
+ print "Moving %r -> %r" % (ofname, fname)
+ shutil.move(ofname, fname)
+ finally:
+ if os.path.exists(ofname):
+ print "Removing %r ..." % (ofname)
+ os.remove(ofname)
+
+# vim: ts=4 et