| 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, bartfab@chromium.org or atwilson@chromium.org. | 6 # mnissler@chromium.org, bartfab@chromium.org or atwilson@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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 enums = (tree.getElementsByTagName('histogram-configuration')[0] | 83 enums = (tree.getElementsByTagName('histogram-configuration')[0] |
| 84 .getElementsByTagName('enums')[0] | 84 .getElementsByTagName('enums')[0] |
| 85 .getElementsByTagName('enum')) | 85 .getElementsByTagName('enum')) |
| 86 policy_enum = [e for e in enums | 86 policy_enum = [e for e in enums |
| 87 if e.getAttribute('name') == 'EnterprisePolicies'][0] | 87 if e.getAttribute('name') == 'EnterprisePolicies'][0] |
| 88 policy_ids = frozenset([int(e.getAttribute('value')) | 88 policy_ids = frozenset([int(e.getAttribute('value')) |
| 89 for e in policy_enum.getElementsByTagName('int')]) | 89 for e in policy_enum.getElementsByTagName('int')]) |
| 90 | 90 |
| 91 error_missing = ('Policy \'%s\' was added to policy_templates.json but not ' | 91 error_missing = ('Policy \'%s\' was added to policy_templates.json but not ' |
| 92 'to src/tools/metrics/histograms/histograms.xml. ' | 92 'to src/tools/metrics/histograms/histograms.xml. ' |
| 93 'Please update both files.') | 93 'Please update both files. To regenerate the policy part ' |
| 94 'of histograms.xml, run:\n' |
| 95 'python tools/metrics/histograms/update_policies.py') |
| 94 results = [] | 96 results = [] |
| 95 for policy in policies: | 97 for policy in policies: |
| 96 if policy['id'] not in policy_ids: | 98 if policy['id'] not in policy_ids: |
| 97 results.append(output_api.PresubmitError(error_missing % policy['name'])) | 99 results.append(output_api.PresubmitError(error_missing % policy['name'])) |
| 98 return results | 100 return results |
| 99 | 101 |
| 100 | 102 |
| 101 def _CommonChecks(input_api, output_api): | 103 def _CommonChecks(input_api, output_api): |
| 102 results = [] | 104 results = [] |
| 103 results.extend(_CheckPolicyTemplatesSyntax(input_api, output_api)) | 105 results.extend(_CheckPolicyTemplatesSyntax(input_api, output_api)) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 117 | 119 |
| 118 return results | 120 return results |
| 119 | 121 |
| 120 | 122 |
| 121 def CheckChangeOnUpload(input_api, output_api): | 123 def CheckChangeOnUpload(input_api, output_api): |
| 122 return _CommonChecks(input_api, output_api) | 124 return _CommonChecks(input_api, output_api) |
| 123 | 125 |
| 124 | 126 |
| 125 def CheckChangeOnCommit(input_api, output_api): | 127 def CheckChangeOnCommit(input_api, output_api): |
| 126 return _CommonChecks(input_api, output_api) | 128 return _CommonChecks(input_api, output_api) |
| OLD | NEW |