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

Side by Side Diff: native_client_sdk/src/tools/oshelpers.py

Issue 13106002: [NaCl SDK] A bunch of spelling fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix presubmit Created 7 years, 8 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 import fnmatch 6 import fnmatch
7 import glob 7 import glob
8 import optparse 8 import optparse
9 import os 9 import os
10 import posixpath 10 import posixpath
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 CopyPath(options, srcfile, dstfile) 101 CopyPath(options, srcfile, dstfile)
102 return 102 return
103 103
104 104
105 def Copy(args): 105 def Copy(args):
106 """A Unix cp style copy. 106 """A Unix cp style copy.
107 107
108 Copies multiple sources to a single destination using the normal cp 108 Copies multiple sources to a single destination using the normal cp
109 semantics. In addition, it support inclusion and exclusion filters which 109 semantics. In addition, it support inclusion and exclusion filters which
110 allows the copy to skip certain types of files.""" 110 allows the copy to skip certain types of files."""
111 parser = optparse.OptionParser(usage='usage: cp [Options] souces... dest') 111 parser = optparse.OptionParser(usage='usage: cp [Options] sources... dest')
112 parser.add_option( 112 parser.add_option(
113 '-R', '-r', '--recursive', dest='recursive', action='store_true', 113 '-R', '-r', '--recursive', dest='recursive', action='store_true',
114 default=False, 114 default=False,
115 help='copy directories recursively.') 115 help='copy directories recursively.')
116 parser.add_option( 116 parser.add_option(
117 '-v', '--verbose', dest='verbose', action='store_true', 117 '-v', '--verbose', dest='verbose', action='store_true',
118 default=False, 118 default=False,
119 help='verbose output.') 119 help='verbose output.')
120 parser.add_option( 120 parser.add_option(
121 '--include', dest='includes', action='append', default=[], 121 '--include', dest='includes', action='append', default=[],
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 for dst in dsts: 166 for dst in dsts:
167 if options.verbose: 167 if options.verbose:
168 print 'mkdir ' + dst 168 print 'mkdir ' + dst
169 try: 169 try:
170 os.makedirs(dst) 170 os.makedirs(dst)
171 except OSError: 171 except OSError:
172 if os.path.isdir(dst): 172 if os.path.isdir(dst):
173 if options.parents: 173 if options.parents:
174 continue 174 continue
175 raise OSError('mkdir: Already exsists: ' + dst) 175 raise OSError('mkdir: Already exists: ' + dst)
176 else: 176 else:
177 raise OSError('mkdir: Failed to create: ' + dst) 177 raise OSError('mkdir: Failed to create: ' + dst)
178 return 0 178 return 0
179 179
180 180
181 def MovePath(options, src, dst): 181 def MovePath(options, src, dst):
182 """MovePath from src to dst 182 """MovePath from src to dst
183 183
184 Moves the src to the dst much like the Unix style mv command, except it 184 Moves the src to the dst much like the Unix style mv command, except it
185 only handles one source at a time. Because of possible temporary failures 185 only handles one source at a time. Because of possible temporary failures
(...skipping 16 matching lines...) Expand all
202 os.rename(src, dst) 202 os.rename(src, dst)
203 return 203 return
204 except OSError as error: 204 except OSError as error:
205 print 'Failed on %s with %s, retrying' % (src, error) 205 print 'Failed on %s with %s, retrying' % (src, error)
206 time.sleep(5) 206 time.sleep(5)
207 print 'Gave up.' 207 print 'Gave up.'
208 raise OSError('mv: ' + error) 208 raise OSError('mv: ' + error)
209 209
210 210
211 def Move(args): 211 def Move(args):
212 parser = optparse.OptionParser(usage='usage: mv [Options] souces... dest') 212 parser = optparse.OptionParser(usage='usage: mv [Options] sources... dest')
213 parser.add_option( 213 parser.add_option(
214 '-v', '--verbose', dest='verbose', action='store_true', 214 '-v', '--verbose', dest='verbose', action='store_true',
215 default=False, 215 default=False,
216 help='verbose output.') 216 help='verbose output.')
217 parser.add_option( 217 parser.add_option(
218 '-f', '--force', dest='force', action='store_true', 218 '-f', '--force', dest='force', action='store_true',
219 default=False, 219 default=False,
220 help='force, do not error it files already exist.') 220 help='force, do not error it files already exist.')
221 options, files = parser.parse_args(args) 221 options, files = parser.parse_args(args)
222 if len(files) < 2: 222 if len(files) < 2:
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 return 1 527 return 1
528 func = FuncMap.get(args[0]) 528 func = FuncMap.get(args[0])
529 if not func: 529 if not func:
530 print 'Do not recognize command: ' + args[0] 530 print 'Do not recognize command: ' + args[0]
531 print 'Available commands: %s' % ' '.join(FuncMap) 531 print 'Available commands: %s' % ' '.join(FuncMap)
532 return 1 532 return 1
533 return func(args[1:]) 533 return func(args[1:])
534 534
535 if __name__ == '__main__': 535 if __name__ == '__main__':
536 sys.exit(main(sys.argv[1:])) 536 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « native_client_sdk/src/tools/getos.py ('k') | native_client_sdk/src/tools/tests/create_nmf_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698