1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Presubmit script for the Braille IME."""
6
7def CheckChangeOnUpload(input_api, output_api):
8  def FileFilter(path):
9    return path.endswith('.js') or path.endswith('check_braille_ime.py')
10  if not any((FileFilter(p) for p in input_api.LocalPaths())):
11    return []
12  import sys
13  if not sys.platform.startswith('linux'):
14    return []
15  sys.path.insert(0, input_api.PresubmitLocalPath())
16  try:
17    from check_braille_ime import CheckBrailleIme
18  finally:
19    sys.path.pop(0)
20  success, output = CheckBrailleIme()
21  if not success:
22    return [output_api.PresubmitError(
23        'Braille IME closure compilation failed',
24        long_text=output)]
25  return []
26