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

Side by Side Diff: tools/metrics/common/presubmit_util.py

Issue 2301093002: predictors: Remove unused histograms for speculative_prefetch_predictor. (Closed)
Patch Set: . Created 4 years, 3 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import os 5 import os
6 import sys 6 import sys
7 import logging 7 import logging
8 import shutil 8 import shutil
9 9
10 sys.path.insert(1, os.path.join(sys.path[0], '..', '..', 'python')) 10 sys.path.append(
11 import google.path_utils 11 os.path.join(os.path.dirname(os.path.abspath(__file__)),
12 os.pardir, os.pardir, 'python', 'google'))
13 import path_utils
12 14
13 import diff_util 15 import diff_util
14 16
15 def DoPresubmitMain(argv, original_filename, backup_filename, script_name, 17 def DoPresubmitMain(argv, original_filename, backup_filename, script_name,
16 prettyFn): 18 prettyFn):
17 """Execute presubmit/pretty printing for the target file. 19 """Execute presubmit/pretty printing for the target file.
18 20
19 Args: 21 Args:
20 argv: command line arguments 22 argv: command line arguments
21 original_filename: The filename to read from. 23 original_filename: The filename to read from.
22 backup_filename: When pretty printing, move the old file contents here. 24 backup_filename: When pretty printing, move the old file contents here.
23 script_name: The name of the script to run for pretty printing. 25 script_name: The name of the script to run for pretty printing.
24 prettyFn: A function which takes the original xml content and produces 26 prettyFn: A function which takes the original xml content and produces
25 pretty printed xml. 27 pretty printed xml.
26 28
27 Returns: 29 Returns:
28 An exit status. Non-zero indicates errors. 30 An exit status. Non-zero indicates errors.
29 """ 31 """
30 logging.basicConfig(level=logging.INFO) 32 logging.basicConfig(level=logging.INFO)
31 presubmit = ('--presubmit' in argv) 33 presubmit = ('--presubmit' in argv)
32 34
33 # If there is a description xml in the current working directory, use that. 35 # If there is a description xml in the current working directory, use that.
34 # Otherwise, use the one residing in the same directory as this script. 36 # Otherwise, use the one residing in the same directory as this script.
35 xml_dir = os.getcwd() 37 xml_dir = os.getcwd()
36 if not os.path.isfile(os.path.join(xml_dir, original_filename)): 38 if not os.path.isfile(os.path.join(xml_dir, original_filename)):
37 xml_dir = google.path_utils.ScriptDir() 39 xml_dir = path_utils.ScriptDir()
38 40
39 xml_path = os.path.join(xml_dir, original_filename) 41 xml_path = os.path.join(xml_dir, original_filename)
40 42
41 # Save the original file content. 43 # Save the original file content.
42 logging.info('Loading %s...', os.path.relpath(xml_path)) 44 logging.info('Loading %s...', os.path.relpath(xml_path))
43 with open(xml_path, 'rb') as f: 45 with open(xml_path, 'rb') as f:
44 original_xml = f.read() 46 original_xml = f.read()
45 47
46 # Check there are no CR ('\r') characters in the file. 48 # Check there are no CR ('\r') characters in the file.
47 if '\r' in original_xml: 49 if '\r' in original_xml:
(...skipping 22 matching lines...) Expand all
70 sys.exit(1) 72 sys.exit(1)
71 73
72 logging.info('Creating backup file: %s', backup_filename) 74 logging.info('Creating backup file: %s', backup_filename)
73 shutil.move(xml_path, os.path.join(xml_dir, backup_filename)) 75 shutil.move(xml_path, os.path.join(xml_dir, backup_filename))
74 76
75 with open(xml_path, 'wb') as f: 77 with open(xml_path, 'wb') as f:
76 f.write(pretty) 78 f.write(pretty)
77 logging.info('Updated %s. Don\'t forget to add it to your changelist', 79 logging.info('Updated %s. Don\'t forget to add it to your changelist',
78 xml_path) 80 xml_path)
79 sys.exit(0) 81 sys.exit(0)
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698