Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/app/policy/PRESUBMIT.py

Issue 6299001: Syntax checker for policy_templates.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/app/policy
Patch Set: address even more comments Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 # If this presubmit check fails or misbehaves, please complain to
6 # gfeher@chromium.org or jkummerow@chromium.org.
7
8 import sys
9
10
11 def _CommonChecks(input_api, output_api):
12 filepath = input_api.os_path.join(input_api.PresubmitLocalPath(),
13 'policy_templates.json')
14 if any(f.AbsoluteLocalPath() == filepath
15 for f in input_api.AffectedFiles()):
16 old_sys_path = sys.path
17 try:
18 sys.path = [input_api.PresubmitLocalPath()] + sys.path
19 # Optimization: only load this when it's needed.
20 import syntax_check_policy_template_json
21 checker = syntax_check_policy_template_json.PolicyTemplateChecker()
22 if checker.Run([], filepath) > 0:
23 return [output_api.PresubmitError('Syntax error(s) in file:',
24 [filepath])]
25 finally:
26 sys.path = old_sys_path
27 return []
28
29
30 def CheckChangeOnUpload(input_api, output_api):
31 return _CommonChecks(input_api, output_api)
32
33
34 def CheckChangeOnCommit(input_api, output_api):
35 return _CommonChecks(input_api, output_api)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698