symbian-qemu-0.9.1-12/python-win32-2.6.1/Tools/Scripts/crlf.py
author asimpson@symbian.org
Thu, 15 Oct 2009 17:58:46 +0100
changeset 14 e6ebb7730c4b
parent 1 2fb8b9db1c86
permissions -rw-r--r--
Added tag PDK_2.0.0 for changeset 52c9f17ec5d1

#! /usr/bin/env python
"Replace CRLF with LF in argument files.  Print names of changed files."

import sys, os

def main():
    for filename in sys.argv[1:]:
        if os.path.isdir(filename):
            print filename, "Directory!"
            continue
        data = open(filename, "rb").read()
        if '\0' in data:
            print filename, "Binary!"
            continue
        newdata = data.replace("\r\n", "\n")
        if newdata != data:
            print filename
            f = open(filename, "wb")
            f.write(newdata)
            f.close()

if __name__ == '__main__':
    main()