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

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

Issue 578303002: Add new braille tables supported by liblouis 2.6.0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@libloiusupgrade
Patch Set: Machines are good at sorting, not me... Created 6 years, 3 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
11 import optparse 11 import optparse
12 12
13 # Matches the include statement in the braille table files. 13 # Matches the include statement in the braille table files.
14 INCLUDE_RE = re.compile(r"^\s*include\s+([^#\s]+)") 14 INCLUDE_RE = re.compile(r"^\s*include\s+([^#\s]+)")
15 15
16 16
17 def Error(msg): 17 def Error(msg):
18 print >> sys.stderr, 'liblouis_list_tables: %s' % msg 18 print >> sys.stderr, 'liblouis_list_tables: %s' % msg
19 sys.exit(1) 19 sys.exit(1)
20 20
21 21
22 def ToNativePath(pathname): 22 def ToNativePath(pathname):
23 return os.path.sep.join(pathname.split('/')) 23 return os.path.sep.join(pathname.split('/'))
24 24
25 25
26 def LoadTablesFile(filename): 26 def LoadTablesFile(filename):
27 with open(ToNativePath(filename), 'r') as fh: 27 with open(ToNativePath(filename), 'r') as fh:
28 return json.load(fh) 28 try:
29 return json.load(fh)
30 except ValueError, e:
31 raise ValueError('Error parsing braille table file %s: %s' %
32 (filename, e.message))
29 33
30 34
31 def FindFile(filename, directories): 35 def FindFile(filename, directories):
32 for d in directories: 36 for d in directories:
33 fullname = '/'.join([d, filename]) 37 fullname = '/'.join([d, filename])
34 if os.path.isfile(ToNativePath(fullname)): 38 if os.path.isfile(ToNativePath(fullname)):
35 return fullname 39 return fullname
36 Error('File not found: %s' % filename) 40 Error('File not found: %s' % filename)
37 41
38 42
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 83
80 def main(argv): 84 def main(argv):
81 print DoMain(argv[1:]) 85 print DoMain(argv[1:])
82 86
83 87
84 if __name__ == '__main__': 88 if __name__ == '__main__':
85 try: 89 try:
86 sys.exit(main(sys.argv)) 90 sys.exit(main(sys.argv))
87 except KeyboardInterrupt: 91 except KeyboardInterrupt:
88 Error('interrupted') 92 Error('interrupted')
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd ('k') | third_party/liblouis/tables.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698