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

Side by Side Diff: tools/refactoring/integratefiles.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/fixnames.py ('k') | tools/refactoring/p4commands.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 stringmanipulation
4 import filemanagement
5 import p4commands
6 import sys
7
8 extensions = ['.h', '.cpp', '.cc', '.gyp']
9
10 ignore_these = ['list_no_stl.h','map_no_stl.h','constructor_magic.h']
11
12 exceptions = [
13 ['GIPSRWLock.h','rw_lock.h'],
14 ['GIPSCriticalsection.h','critical_section.h'],
15 ]
16
17 if((len(sys.argv) != 4) and (len(sys.argv) != 5)):
18 print 'parameters are: parent directory extension new extension [--commit]'
19 quit()
20
21 directory = sys.argv[1];
22 if(not filemanagement.pathexist(directory)):
23 print 'path ' + directory + ' does not exist'
24 quit()
25
26 old_extension = sys.argv[2]
27 if(not stringmanipulation.isextension(old_extension)):
28 print old_extension + ' is not a valid extension'
29 quit()
30
31 new_extension = sys.argv[3]
32 if(not stringmanipulation.isextension(new_extension)):
33 print new_extension + ' is not a valid extension'
34 quit()
35
36 if((len(sys.argv) == 5) and (sys.argv[4] != '--commit')):
37 print 'parameters are: parent directory extension new extension [--commit]'
38 quit()
39
40 commit = False
41 if(len(sys.argv) == 5):
42 commit = True
43
44 files_to_integrate = filemanagement.listallfilesinfolder(directory,\
45 old_extension)
46
47 if(commit):
48 p4commands.checkoutallfiles()
49 for index in range(len(files_to_integrate)):
50 if(commit):
51 print (100*index)/len(files_to_integrate)
52 path_dir = files_to_integrate[index][0]
53 filename = files_to_integrate[index][1]
54 is_ignore = False
55 for ignore_names in ignore_these:
56 if(filename == ignore_names):
57 is_ignore = True
58 break
59 if(is_ignore):
60 continue
61
62 new_file_name = ''
63 is_exception = False
64 for exception_name,exception_name_new in exceptions:
65 if(filename == exception_name):
66 is_exception = True
67 new_file_name = exception_name_new
68 break
69
70 if(not is_exception):
71 new_file_name = filename
72
73 new_file_name = stringmanipulation.removeallprefix(new_file_name,\
74 'gips')
75 new_file_name = stringmanipulation.removealloccurances(new_file_name,\
76 'module')
77 new_file_name = stringmanipulation.changeextension(new_file_name,\
78 old_extension,\
79 new_extension)
80 new_file_name = stringmanipulation.fixabbreviations( new_file_name )
81 new_file_name = stringmanipulation.lowercasewithunderscore(new_file_name )
82 if(not commit):
83 print 'File ' + filename + ' will be replaced with ' + new_file_name
84 continue
85 full_new_file_name = path_dir + new_file_name
86 full_old_file_name = path_dir + filename
87 if(full_new_file_name != full_old_file_name):
88 p4commands.integratefile(full_old_file_name,full_new_file_name)
89 else:
90 print 'skipping ' + new_file_name + ' due to no change'
91 for extension in extensions:
92 print 'replacing ' + filename
93 if (extension == ".gyp"):
94 filemanagement.replacestringinallsubfolders(
95 filename,new_file_name,extension)
96 else:
97 filemanagement.replacestringinallsubfolders(
98 '\"' + filename + '\"', '\"' + new_file_name + '\"', extension)
99 if(commit):
100 p4commands.revertunchangedfiles()
OLDNEW
« no previous file with comments | « tools/refactoring/fixnames.py ('k') | tools/refactoring/p4commands.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698