A python script to show line endings in use

I get fed up with trying to quickly check line endings in files – especially when I am working with a file format that absolutely requires DOS line endings \r\n.

#!/usr/bin/python

import sys
import os

print 'Number of files given as args: ', len(sys.argv)

padding = 20

for file in sys.argv:
    if os.path.isfile(file):
        if "\r\n" in open(file,"rb").read():
            print str(file).ljust(padding, " ")," : DOS line endings found"
            continue
        if "\n" in open(file,"rb").read():
            print  str(file).ljust(padding, " "), " : UNIX line endings found"
            continue
        if "\r" in open(file,"rb").read():
            print str(file).ljust(padding, " ")," : MAC line endings found"