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

Side by Side Diff: tools/sort-headers.py

Issue 7048007: Move scoped_temp_dir and scoped_native_library back from base/memory to base. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unknwn Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/json_host_config_unittest.cc ('k') | ui/base/resource/data_pack_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Given a filename as an argument, sort the #include/#imports in that file. 6 """Given a filename as an argument, sort the #include/#imports in that file.
7 7
8 Shows a diff and prompts for confirmation before doing the deed. 8 Shows a diff and prompts for confirmation before doing the deed.
9 """ 9 """
10 10
(...skipping 24 matching lines...) Expand all
35 """Sorting comparator key used for comparing two #include lines. 35 """Sorting comparator key used for comparing two #include lines.
36 Returns the filename without the #include/#import prefix. 36 Returns the filename without the #include/#import prefix.
37 """ 37 """
38 for prefix in ('#include ', '#import '): 38 for prefix in ('#include ', '#import '):
39 if line.startswith(prefix): 39 if line.startswith(prefix):
40 line = line[len(prefix):] 40 line = line[len(prefix):]
41 break 41 break
42 # <windows.h> needs to be before other includes, so return a key 42 # <windows.h> needs to be before other includes, so return a key
43 # that's less than all other keys. 43 # that's less than all other keys.
44 if line.lstrip().startswith('<windows.h>'): 44 if line.lstrip().startswith('<windows.h>'):
45 return '' 45 return ' 0'
46 if line.lstrip().startswith('<unknwn.h>'):
47 return ' 1'
46 return line 48 return line
47 49
48 50
49 def IsInclude(line): 51 def IsInclude(line):
50 """Returns True if the line is an #include/#import line.""" 52 """Returns True if the line is an #include/#import line."""
51 return line.startswith('#include ') or line.startswith('#import ') 53 return line.startswith('#include ') or line.startswith('#import ')
52 54
53 55
54 def SortHeader(infile, outfile): 56 def SortHeader(infile, outfile):
55 """Sorts the headers in infile, writing the sorted file to outfile.""" 57 """Sorts the headers in infile, writing the sorted file to outfile."""
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 finally: 95 finally:
94 try: 96 try:
95 os.remove(fixfilename) 97 os.remove(fixfilename)
96 except OSError: 98 except OSError:
97 # If the file isn't there, we don't care. 99 # If the file isn't there, we don't care.
98 pass 100 pass
99 101
100 102
101 if __name__ == '__main__': 103 if __name__ == '__main__':
102 main() 104 main()
OLDNEW
« no previous file with comments | « remoting/host/json_host_config_unittest.cc ('k') | ui/base/resource/data_pack_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698