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

Side by Side Diff: third_party/liblouis/liblouis_list_tables.py

Issue 1145243006: Port chromevox build to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@externs
Patch Set: Unshare some vars, add TODO for the rest. Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 os 6 import os
7 import re 7 import re
8 import sys 8 import sys
9 9
10 import json 10 import json
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 def ProcessFile(output_set, filename, directories): 53 def ProcessFile(output_set, filename, directories):
54 fullname = FindFile(filename, directories) 54 fullname = FindFile(filename, directories)
55 if fullname in output_set: 55 if fullname in output_set:
56 return 56 return
57 output_set.add(fullname) 57 output_set.add(fullname)
58 for include_file in GetIncludeFiles(fullname): 58 for include_file in GetIncludeFiles(fullname):
59 ProcessFile(output_set, include_file, directories) 59 ProcessFile(output_set, include_file, directories)
60 60
61 61
62 def GetTableFiles(tables_file, directories, extra_files):
63 tables = LoadTablesFile(tables_file)
64 output_set = set()
65 for table in tables:
66 for name in table['fileNames'].split(','):
67 ProcessFile(output_set, name, directories)
68 for name in extra_files:
69 ProcessFile(output_set, name, directories)
70 return output_set
71
72
62 def DoMain(argv): 73 def DoMain(argv):
63 "Entry point for gyp's pymod_do_main command." 74 "Entry point for gyp's pymod_do_main command."
64 parser = optparse.OptionParser() 75 parser = optparse.OptionParser()
65 # Give a clearer error message when this is used as a module. 76 # Give a clearer error message when this is used as a module.
66 parser.prog = 'liblouis_list_tables' 77 parser.prog = 'liblouis_list_tables'
67 parser.set_usage('usage: %prog [options] listfile') 78 parser.set_usage('usage: %prog [options] listfile')
68 parser.add_option('-D', '--directory', dest='directories', 79 parser.add_option('-D', '--directory', dest='directories',
69 action='append', help='Where to search for table files') 80 action='append', help='Where to search for table files')
70 parser.add_option('-e', '--extra_file', dest='extra_files', action='append', 81 parser.add_option('-e', '--extra_file', dest='extra_files', action='append',
71 default=[], help='Extra liblouis table file to process') 82 default=[], help='Extra liblouis table file to process')
72 (options, args) = parser.parse_args(argv) 83 (options, args) = parser.parse_args(argv)
73 84
74 if len(args) != 1: 85 if len(args) != 1:
75 parser.error('Expecting exactly one argument') 86 parser.error('Expecting exactly one argument')
76 if not options.directories: 87 if not options.directories:
77 parser.error('At least one --directory option must be specified') 88 parser.error('At least one --directory option must be specified')
78 89 files = GetTableFiles(args[0], options.directories, options.extra_files)
79 tables = LoadTablesFile(args[0]) 90 return '\n'.join(files)
80 output_set = set()
81 for table in tables:
82 for name in table['fileNames'].split(','):
83 ProcessFile(output_set, name, options.directories)
84 for name in options.extra_files:
85 ProcessFile(output_set, name, options.directories)
86 return '\n'.join(output_set)
87 91
88 92
89 def main(argv): 93 def main(argv):
90 print DoMain(argv[1:]) 94 print DoMain(argv[1:])
91 95
92 96
93 if __name__ == '__main__': 97 if __name__ == '__main__':
94 try: 98 try:
95 sys.exit(main(sys.argv)) 99 sys.exit(main(sys.argv))
96 except KeyboardInterrupt: 100 except KeyboardInterrupt:
97 Error('interrupted') 101 Error('interrupted')
OLDNEW
« chrome/browser/resources/chromeos/chromevox/BUILD.gn ('K') | « third_party/liblouis/copy_tables.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698