from __future__ import * 8.11.2003

2003-11-08

Yet Another Line Ending Conversion Program

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.

#!/usr/bin/env python
import sys, os, shutil
from cStringIO import StringIO

def tonative(fname):
    buff = StringIO()
    infile = file(fname, 'rU')
    infile.readline()
    infile.seek(0)
    if infile.newlines == os.linesep:
        return
    for line in infile:
        buff.write(line.strip() + os.linesep)
    infile.close()
    outfile = file(fname, 'wb')
    buff.seek(0)
    shutil.copyfileobj(buff, outfile)
    outfile.close()

if __name__ == '__main__':
    for fname in sys.argv[1:]:
        tonative(fname)

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.

posted at 15:52:16    #    comment []    trackback []
 

First thoughts about PyDS

  • It's not always responsive. Needs to be refactored to be more async.

  • There should be a button that rewrites your preview. I can't get it to refresh after editing a blog entry?

  • What the heck are those timers? Why are there 4 "backup databases" in the list? Can I edit them? Is that what add means?

  • What's an enclosure?

  • (Maybe a PyCS question) how do I get notified when someone comments?

  • How do I put syntax highlighted Python code in a structured text entry? Do I have to hack the code, or just do it as HTML and use another tool?

posted at 01:20:48    #    comment []    trackback []
November
MoTuWeThFrSaSu
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930
Oct Dec

Bob's Rants

XML-Image Letterimage

© 2003-2004, Bob Ippolito