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

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

Issue 8678023: Fix python scripts in src/tools/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes Created 9 years 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 | « tools/site_compare/utils/browser_iterate.py ('k') | tools/swig/swig.py » ('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/env 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 Works great with tools/git/for-all-touched-files.py. 9 Works great with tools/git/for-all-touched-files.py.
10 """ 10 """
11 11
12 import optparse 12 import optparse
13 import os 13 import os
14 import sys 14 import sys
15 import termios 15 import termios
16 import tty 16 import tty
17 17
18
18 def YesNo(prompt): 19 def YesNo(prompt):
19 """Prompts with a yes/no question, returns True if yes.""" 20 """Prompts with a yes/no question, returns True if yes."""
20 print prompt, 21 print prompt,
21 sys.stdout.flush() 22 sys.stdout.flush()
22 # http://code.activestate.com/recipes/134892/ 23 # http://code.activestate.com/recipes/134892/
23 fd = sys.stdin.fileno() 24 fd = sys.stdin.fileno()
24 old_settings = termios.tcgetattr(fd) 25 old_settings = termios.tcgetattr(fd)
25 ch = 'n' 26 ch = 'n'
26 try: 27 try:
27 tty.setraw(sys.stdin.fileno()) 28 tty.setraw(sys.stdin.fileno())
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 def main(): 105 def main():
105 parser = optparse.OptionParser(usage='%prog filename1 filename2 ...') 106 parser = optparse.OptionParser(usage='%prog filename1 filename2 ...')
106 parser.add_option('-f', '--force', action='store_false', default=True, 107 parser.add_option('-f', '--force', action='store_false', default=True,
107 dest='should_confirm', 108 dest='should_confirm',
108 help='Turn off confirmation prompt.') 109 help='Turn off confirmation prompt.')
109 opts, filenames = parser.parse_args() 110 opts, filenames = parser.parse_args()
110 111
111 if len(filenames) < 1: 112 if len(filenames) < 1:
112 parser.print_help() 113 parser.print_help()
113 sys.exit(1) 114 return 1
114 115
115 for filename in filenames: 116 for filename in filenames:
116 DiffAndConfirm(filename, opts.should_confirm) 117 DiffAndConfirm(filename, opts.should_confirm)
117 118
118 119
119 if __name__ == '__main__': 120 if __name__ == '__main__':
120 main() 121 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/site_compare/utils/browser_iterate.py ('k') | tools/swig/swig.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698