|
Last change
on this file since 1538 was 2, checked in by Yuri Dario, 15 years ago |
|
Initial import for vendor code.
|
-
Property svn:eol-style
set to
native
|
|
File size:
619 bytes
|
| Line | |
|---|
| 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 |
|
|---|
| 7 | def main():
|
|---|
| 8 | for filename in sys.argv[1:]:
|
|---|
| 9 | if os.path.isdir(filename):
|
|---|
| 10 | print filename, "Directory!"
|
|---|
| 11 | continue
|
|---|
| 12 | data = open(filename, "rb").read()
|
|---|
| 13 | if '\0' in data:
|
|---|
| 14 | print filename, "Binary!"
|
|---|
| 15 | continue
|
|---|
| 16 | newdata = re.sub("\r?\n", "\r\n", data)
|
|---|
| 17 | if newdata != data:
|
|---|
| 18 | print filename
|
|---|
| 19 | f = open(filename, "wb")
|
|---|
| 20 | f.write(newdata)
|
|---|
| 21 | f.close()
|
|---|
| 22 |
|
|---|
| 23 | if __name__ == '__main__':
|
|---|
| 24 | main()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.