1#!/usr/bin/python
2#
3# Copyright 2012 The Native Client Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6# Copyright 2012, Google Inc.
7#
8
9"""Table optimizer script.
10
11Usage: optimize_table.py <input-table> <output-table>
12"""
13
14from __future__ import print_function
15
16import sys
17import dgen_input
18import dgen_dump
19
20def main(argv):
21  in_filename, out_filename = argv[1], argv[2]
22
23  print("Optimizer reading ", in_filename)
24  f = open(in_filename, 'r')
25  tables = dgen_input.parse_tables(f)
26  f.close()
27
28  print("Successful - got %d tables." % len(tables))
29
30  print("Generating output to %s..." % out_filename)
31  f = open(out_filename, 'w')
32  dgen_dump.dump_tables(tables, f)
33  f.close()
34  print("Completed.")
35
36  return 0
37
38
39if __name__ == '__main__':
40  sys.exit(main(sys.argv))
41