Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: tools/refactoring/trimall.py

Issue 1581573003: Remove tools/refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/refactoring/trim.py ('k') | tools/refactoring/webrtc_reformat.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 import sys
4 import fileinput
5 import filemanagement
6 import p4commands
7
8 # Defaults
9 TABSIZE = 4
10
11 extensions = ['.h','.cc','.c','.cpp']
12
13 ignore_these = ['my_ignore_header.h']
14
15 usage = """
16 Replaces all TAB characters with %(TABSIZE)d space characters.
17 In addition, all trailing space characters are removed.
18 usage: trim directory
19 """ % vars()
20
21 if((len(sys.argv) != 2) and (len(sys.argv) != 3)):
22 sys.stderr.write(usage)
23 sys.exit(2)
24
25 directory = sys.argv[1];
26 if(not filemanagement.pathexist(directory)):
27 sys.stderr.write(usage)
28 sys.exit(2)
29
30 if((len(sys.argv) == 3) and (sys.argv[2] != '--commit')):
31 sys.stderr.write(usage)
32 sys.exit(2)
33
34 commit = False
35 if(len(sys.argv) == 3):
36 commit = True
37
38 files_to_fix = []
39 for extension in extensions:
40 files_to_fix.extend(filemanagement.listallfilesinfolder(directory,\
41 extension))
42
43 def main():
44 if (commit):
45 p4commands.checkoutallfiles()
46 for path,file_name in files_to_fix:
47 full_file_name = path + file_name
48 if (not commit):
49 print full_file_name + ' will be edited'
50 continue
51 for line in fileinput.input(full_file_name, inplace=True):
52 line = line.replace('\t',' '*TABSIZE); # replace TABs
53 line = line.rstrip(None) # remove trailing whitespaces
54 print line # modify the file
55 if (commit):
56 p4commands.revertunchangedfiles()
57
58 if __name__ == '__main__':
59 main()
OLDNEW
« no previous file with comments | « tools/refactoring/trim.py ('k') | tools/refactoring/webrtc_reformat.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698