Winston Wolff wrote:
• The ^M characters are since I am using Mac OS X and my editor defaults to Unix file endings. I believe the python interpreter reads this fine, it just appears funny in your editor. Is there a file-ending convention for Webware that I should switch to?
Just in case anyone cares...
Having to develop on *nix and Windows, I got tired of dealing with the ^Ms in my code files so I wrote a little python script to clean up the files. It should convert line endings to whatever your current system uses. For better or worse, I've posted the code below.
--John
#!/usr/bin/env python2.4
import sys
def main(args):
for x in xrange(len(args)):
f = open(args[x],'r')
lines = f.readlines()
f.close()
f = open(args[x],'wb')
for j in lines:
if j[-2:] == '\r\n':
# windows format
f.write(j[:-2]+'\n')
elif j[-1:] == '\n':
# *nix format
f.write(j[:-1]+'\n')
elif j[-1:] == '\r':
# mac format
f.write(j[:-1]+'\n')
f.close()if __name__ == '__main__': if len(sys.argv) < 2: print 'Usage Error!' print 'Usage: %s file1 file2 ...' % sys.argv[0] sys.exit(1) sys.argv.pop(0) main(sys.argv)
------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Webware-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/webware-discuss
