##// END OF EJS Templates
Cleanup check_sources and remove hard tabs from some files....
Fernando Perez -
Show More
1 NO CONTENT: modified file
NO CONTENT: modified file
1 NO CONTENT: modified file
NO CONTENT: modified file
1 NO CONTENT: modified file chmod 100755 => 100644, modified file
NO CONTENT: modified file chmod 100755 => 100644, modified file
1 NO CONTENT: modified file
NO CONTENT: modified file
1 NO CONTENT: modified file
NO CONTENT: modified file
1 NO CONTENT: modified file
NO CONTENT: modified file
@@ -1,32 +1,54 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Utility to look for hard tabs and \r characters in all sources.
2 """Utility to look for hard tabs and \r characters in all sources.
3
4 Usage:
5
6 ./check_sources.py
7
8 It prints summaries and if chosen, line-by-line info of where \\t or \\r
9 characters can be found in our source tree.
3 """
10 """
4
11
5 from IPython.external.path import path
12 # Config
13 # If true, all lines that have tabs are printed, with line number
14 full_report_tabs = True
15 # If true, all lines that have tabs are printed, with line number
16 full_report_rets = False
6
17
7 fs = path('..').walkfiles('*.py')
18 # Code begins
19 from IPython.external.path import path
8
20
9 rets = []
21 rets = []
22 tabs = []
10
23
11 for f in fs:
24 for f in path('..').walkfiles('*.py'):
12 errs = ''
25 errs = ''
13 cont = f.bytes()
26 cont = f.bytes()
14 if '\t' in cont:
27 if '\t' in cont:
15 errs+='t'
28 errs+='t'
29 tabs.append(f)
16
30
17 if '\r' in cont:
31 if '\r' in cont:
18 errs+='r'
32 errs+='r'
19 rets.append(f)
33 rets.append(f)
20
34
21 if errs:
35 if errs:
22 print "%3s" % errs, f
36 print "%3s" % errs, f
23 if 't' in errs:
37
38 if 't' in errs and full_report_tabs:
24 for ln,line in enumerate(f.lines()):
39 for ln,line in enumerate(f.lines()):
25 if '\t' in line:
40 if '\t' in line:
26 print 'TAB:',ln,':',line,
41 print 'TAB:',ln,':',line,
27 if 'r' in errs:
42
43 if 'r' in errs and full_report_rets:
28 for ln,line in enumerate(open(f.abspath(),'rb')):
44 for ln,line in enumerate(open(f.abspath(),'rb')):
29 if '\r' in line:
45 if '\r' in line:
30 print 'RET:',ln,':',line,
46 print 'RET:',ln,':',line,
31
47
32 rr = rets[-1]
48 # Summary at the end, to call cleanup tools if necessary
49 if tabs:
50 print 'Hard tabs found. These can be cleaned with untabify:'
51 for f in tabs: print f,
52 if rets:
53 print 'Carriage returns (\\r) found in:'
54 for f in rets: print f,
General Comments 0
You need to be logged in to leave comments. Login now