| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Simple testing utility to just run the mojom translate stage.""" | 6 """Simple testing utility to just run the mojom translate stage.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import os.path | 9 import os.path |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), | 12 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 13 os.path.pardir, os.path.pardir)) | 13 os.path.pardir, os.path.pardir)) |
| 14 | 14 |
| 15 # Disable lint check for finding modules: | |
| 16 # pylint: disable=F0401 | |
| 17 | |
| 18 from mojom.parse.parser import Parse | 15 from mojom.parse.parser import Parse |
| 19 from mojom.parse.translate import Translate | 16 from mojom.parse.translate import Translate |
| 20 | 17 |
| 21 | 18 |
| 22 def main(argv): | 19 def main(argv): |
| 23 if len(argv) < 2: | 20 if len(argv) < 2: |
| 24 print "usage: %s filename" % sys.argv[0] | 21 print "usage: %s filename" % sys.argv[0] |
| 25 return 1 | 22 return 1 |
| 26 | 23 |
| 27 for filename in argv[1:]: | 24 for filename in argv[1:]: |
| 28 with open(filename) as f: | 25 with open(filename) as f: |
| 29 print "%s:" % filename | 26 print "%s:" % filename |
| 30 print Translate(Parse(f.read(), filename), | 27 print Translate(Parse(f.read(), filename), |
| 31 os.path.splitext(os.path.basename(filename))[0]) | 28 os.path.splitext(os.path.basename(filename))[0]) |
| 32 | 29 |
| 33 return 0 | 30 return 0 |
| 34 | 31 |
| 35 | 32 |
| 36 if __name__ == '__main__': | 33 if __name__ == '__main__': |
| 37 sys.exit(main(sys.argv)) | 34 sys.exit(main(sys.argv)) |
| OLD | NEW |