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

Side by Side Diff: native_client_sdk/src/build_tools/dsc2gyp.py

Issue 720233003: [NaCl SDK] Convert python scripts from optparse to argparse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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
6 import argparse
5 import StringIO 7 import StringIO
6 import sys 8 import sys
7 import os 9 import os
8 import optparse
9 10
10 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 11 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
11 sys.path.append(os.path.join(os.path.dirname(SCRIPT_DIR), 'tools')) 12 sys.path.append(os.path.join(os.path.dirname(SCRIPT_DIR), 'tools'))
12 13
13 import getos 14 import getos
14 15
15 valid_tools = ['newlib', 'glibc', getos.GetPlatform()] 16 valid_tools = ['newlib', 'glibc', getos.GetPlatform()]
16 17
17 18
18 def Error(msg): 19 def Error(msg):
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 else: 353 else:
353 output.write(HOST_LIB_TARGET % target) 354 output.write(HOST_LIB_TARGET % target)
354 355
355 output.write(' ],\n}\n') 356 output.write(' ],\n}\n')
356 357
357 print('Writing: ' + outfile) 358 print('Writing: ' + outfile)
358 open(outfile, 'w').write(output.getvalue()) 359 open(outfile, 'w').write(output.getvalue())
359 360
360 361
361 def main(args): 362 def main(args):
362 parser = optparse.OptionParser() 363 parser = argparse.ArgumentParser()
363 parser.add_option('-o', help='Set output filename.', dest='output') 364 parser.add_argument('-o', help='Set output filename.', dest='output')
364 options, args = parser.parse_args(args) 365 parser.add_argument('dsc', help='dsc to convert')
365 if not args: 366 options = parser.parse_args(args)
366 Error('No .dsc file specified.')
367 367
368 if options.output: 368 if options.output:
369 outdir = os.path.dirname(options.output) 369 outdir = os.path.dirname(options.output)
370 if not os.path.exists(outdir): 370 if not os.path.exists(outdir):
371 os.makedirs(outdir) 371 os.makedirs(outdir)
372 372
373 assert len(args) == 1 373 ProcessDSC(options.dsc, options.output)
374 ProcessDSC(args[0], options.output)
375 return 0 374 return 0
376 375
377 376
378 if __name__ == '__main__': 377 if __name__ == '__main__':
379 sys.exit(main(sys.argv[1:])) 378 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/buildbot_run.py ('k') | native_client_sdk/src/build_tools/dsc_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698