mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Initial revision
This commit is contained in:
parent
fe16cc0338
commit
dc0493ac67
4 changed files with 686 additions and 0 deletions
25
Mac/scripts/crlf.py
Executable file
25
Mac/scripts/crlf.py
Executable file
|
@ -0,0 +1,25 @@
|
|||
#! /usr/local/bin/python
|
||||
|
||||
import sys
|
||||
import os
|
||||
import string
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
print 'no files'
|
||||
sys.exit(1)
|
||||
for file in args:
|
||||
print file, '...'
|
||||
data = open(file, 'r').read()
|
||||
lines = string.splitfields(data, '\r')
|
||||
newdata = string.joinfields(lines, '\n')
|
||||
if newdata != data:
|
||||
print 'rewriting...'
|
||||
os.rename(file, file + '~')
|
||||
open(file, 'w').write(newdata)
|
||||
print 'done.'
|
||||
else:
|
||||
print 'no change.'
|
||||
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue