forked from fabioz/Pydev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_new_lines.py
31 lines (30 loc) · 985 Bytes
/
fix_new_lines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
if __name__ == '__main__':
import os
for root, dirs, files in os.walk(os.curdir):
for file in files:
file = file.lower()
#import pdb;pdb.set_trace()
if os.path.splitext(file)[1] in (
'.py',
'.pyw',
'.java',
'.xml',
'.html',
'.htm',
'.txt',
# '.launch',
'.diff',
'.jjt',
'.jjt_template',
'.project',
'.pydevproject',
'.css',
'.exsd',
'.mf'
):
path = os.path.join(root, file)
contents = open(path, 'rb').read()
if '\r' in contents:
print path
contents = contents.replace('\r\n', '\n').replace('\r','\n')
open(path, 'wb').write(contents)