Index: chrome/app/policy/PRESUBMIT.py |
diff --git a/chrome/app/policy/PRESUBMIT.py b/chrome/app/policy/PRESUBMIT.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..948015401caad2dbb1575d5c61086fbf912c772d |
--- /dev/null |
+++ b/chrome/app/policy/PRESUBMIT.py |
@@ -0,0 +1,36 @@ |
+# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import os |
+import sys |
+import traceback |
+ |
+ |
+def _CommonChecks(input_api, output_api): |
+ try: |
+ filename = 'policy_templates.json' |
+ results = [] |
+ for f in input_api.AffectedFiles(): |
+ if f.AbsoluteLocalPath() == os.path.join(input_api.PresubmitLocalPath(), |
+ filename): |
+ sys.path.append(input_api.PresubmitLocalPath()) |
+ import syntax_check_policy_template_json |
+ checker = syntax_check_policy_template_json.PolicyTemplateChecker() |
+ result = checker.Run([], f.AbsoluteLocalPath()) |
+ if result > 0: |
+ results.append(output_api.PresubmitError( |
+ 'Syntax error(s) in file:', [f])) |
+ return results |
+ except: |
+ print "exception :-(" |
+ traceback.print_exc(file=sys.stdout) |
+ return results |
+ |
+ |
+def CheckChangeOnUpload(input_api, output_api): |
+ return _CommonChecks(input_api, output_api) |
+ |
+ |
+def CheckChangeOnCommit(input_api, output_api): |
+ return _CommonChecks(input_api, output_api) |