This is what I've been using.. it's really simple, and should convert Win32, Mac, or Unix line endings to whatever your native line ending is. A possible future optimization would be to use temp files instead, but they're annoying.
import sys, os, shutil
from cStringIO import StringIO
buff = StringIO()
infile = file(fname, 'rU')
if infile.newlines == os.linesep:
for line in infile:
buff.write(line.strip() + os.linesep)
outfile = file(fname, 'wb')
if __name__ == '__main__':
for fname in sys.argv[1:]:
Is there any way to syntax highlight Python code in PyDS structured text?
Update: There is now, but I had to write it :) Details coming shortly.