[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / telemetry / PRESUBMIT.py
blobb3761897dcb1120cdf00e51c4ea8c1b789e83da1
1 # Copyright 2012 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 import os
5 import sys
7 PYLINT_BLACKLIST = []
8 PYLINT_DISABLED_WARNINGS = ['R0923', 'R0201', 'E1101']
10 def _CommonChecks(input_api, output_api):
11 results = []
13 # TODO(nduca): This should call update_docs.IsUpdateDocsNeeded().
14 # Disabled due to crbug.com/255326.
15 if False:
16 update_docs_path = os.path.join(
17 input_api.PresubmitLocalPath(), 'update_docs')
18 assert os.path.exists(update_docs_path)
19 results.append(output_api.PresubmitError(
20 'Docs are stale. Please run:\n' +
21 '$ %s' % os.path.abspath(update_docs_path)))
23 results.extend(input_api.canned_checks.RunPylint(
24 input_api, output_api,
25 black_list=PYLINT_BLACKLIST,
26 disabled_warnings=PYLINT_DISABLED_WARNINGS))
27 return results
29 def GetPathsToPrepend(input_api):
30 return [input_api.PresubmitLocalPath(),
31 os.path.join(input_api.PresubmitLocalPath(), os.path.pardir,
32 os.path.pardir, 'third_party', 'typ')]
34 def RunWithPrependedPath(prepended_path, fn, *args):
35 old_path = sys.path
37 try:
38 sys.path = prepended_path + old_path
39 return fn(*args)
40 finally:
41 sys.path = old_path
43 def CheckChangeOnUpload(input_api, output_api):
44 def go():
45 results = []
46 results.extend(_CommonChecks(input_api, output_api))
47 return results
48 return RunWithPrependedPath(GetPathsToPrepend(input_api), go)
50 def CheckChangeOnCommit(input_api, output_api):
51 def go():
52 results = []
53 results.extend(_CommonChecks(input_api, output_api))
54 return results
55 return RunWithPrependedPath(GetPathsToPrepend(input_api), go)