| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # If this presubmit check fails or misbehaves, please complain to | 5 # If this presubmit check fails or misbehaves, please complain to |
| 6 # mnissler@chromium.org, pastarmovj@chromium.org or joaodasilva@chromium.org. | 6 # mnissler@chromium.org, pastarmovj@chromium.org or joaodasilva@chromium.org. |
| 7 | 7 |
| 8 import itertools | 8 import itertools |
| 9 import sys | 9 import sys |
| 10 import xml.dom.minidom | 10 import xml.dom.minidom |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 def _CommonChecks(input_api, output_api): | 99 def _CommonChecks(input_api, output_api): |
| 100 results = [] | 100 results = [] |
| 101 results.extend(_CheckPolicyTemplatesSyntax(input_api, output_api)) | 101 results.extend(_CheckPolicyTemplatesSyntax(input_api, output_api)) |
| 102 | 102 |
| 103 os_path = input_api.os_path | 103 os_path = input_api.os_path |
| 104 local_path = input_api.PresubmitLocalPath() | 104 local_path = input_api.PresubmitLocalPath() |
| 105 template_path = os_path.join(local_path, 'policy_templates.json') | 105 template_path = os_path.join(local_path, 'policy_templates.json') |
| 106 affected_files = input_api.AffectedFiles() | 106 affected_files = input_api.AffectedFiles() |
| 107 if any(f.AbsoluteLocalPath() == template_path for f in affected_files): | 107 if any(f.AbsoluteLocalPath() == template_path for f in affected_files): |
| 108 policies = _GetPolicyTemplates(template_path) | 108 try: |
| 109 policies = _GetPolicyTemplates(template_path) |
| 110 except: |
| 111 results.append(output_api.PresubmitError('Invalid Python/JSON syntax.')) |
| 112 return results |
| 109 results.extend(_CheckPolicyTestCases(input_api, output_api, policies)) | 113 results.extend(_CheckPolicyTestCases(input_api, output_api, policies)) |
| 110 results.extend(_CheckPolicyHistograms(input_api, output_api, policies)) | 114 results.extend(_CheckPolicyHistograms(input_api, output_api, policies)) |
| 111 | 115 |
| 112 return results | 116 return results |
| 113 | 117 |
| 114 | 118 |
| 115 def CheckChangeOnUpload(input_api, output_api): | 119 def CheckChangeOnUpload(input_api, output_api): |
| 116 return _CommonChecks(input_api, output_api) | 120 return _CommonChecks(input_api, output_api) |
| 117 | 121 |
| 118 | 122 |
| 119 def CheckChangeOnCommit(input_api, output_api): | 123 def CheckChangeOnCommit(input_api, output_api): |
| 120 return _CommonChecks(input_api, output_api) | 124 return _CommonChecks(input_api, output_api) |
| OLD | NEW |