repo.or.cz
/
python
/
dscho.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Move setting of ioready 'wait' earlier in call chain, to
[python/dscho.git]
/
Tools
/
scripts
/
lfcr.py
blob
5f67fe00c214a74dc1a3f7813870c473e011e277
1
#! /usr/bin/env python
2
3
"Replace LF with CRLF in argument files. Print names of changed files."
4
5
import
sys
,
re
,
os
6
for
file
in
sys
.
argv
[
1
:]:
7
if
os
.
path
.
isdir
(
file
):
8
print
file
,
"Directory!"
9
continue
10
data
=
open
(
file
,
"rb"
).
read
()
11
if
'\0'
in
data
:
12
print
file
,
"Binary!"
13
continue
14
newdata
=
re
.
sub
(
"
\r
?
\n
"
,
"
\r\n
"
,
data
)
15
if
newdata
!=
data
:
16
print
file
17
f
=
open
(
file
,
"wb"
)
18
f
.
write
(
newdata
)
19
f
.
close
()