OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2011 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 import os |
| 6 import sys |
| 7 import traceback |
| 8 |
| 9 |
| 10 def _CommonChecks(input_api, output_api): |
| 11 try: |
| 12 filename = 'policy_templates.json' |
| 13 results = [] |
| 14 for f in input_api.AffectedFiles(): |
| 15 if f.AbsoluteLocalPath() == os.path.join(input_api.PresubmitLocalPath(), |
| 16 filename): |
| 17 sys.path.append(input_api.PresubmitLocalPath()) |
| 18 import syntax_check_policy_template_json |
| 19 checker = syntax_check_policy_template_json.PolicyTemplateChecker() |
| 20 result = checker.Run([], f.AbsoluteLocalPath()) |
| 21 if result > 0: |
| 22 results.append(output_api.PresubmitError( |
| 23 'Syntax error(s) in file:', [f])) |
| 24 return results |
| 25 except: |
| 26 print "exception :-(" |
| 27 traceback.print_exc(file=sys.stdout) |
| 28 return results |
| 29 |
| 30 |
| 31 def CheckChangeOnUpload(input_api, output_api): |
| 32 return _CommonChecks(input_api, output_api) |
| 33 |
| 34 |
| 35 def CheckChangeOnCommit(input_api, output_api): |
| 36 return _CommonChecks(input_api, output_api) |
OLD | NEW |