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

Side by Side Diff: tools/metrics/histograms/pretty_print.py

Issue 513803005: Remove obsolete fieldtrial related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « tools/metrics/histograms/extract_histograms.py ('k') | tools/metrics/histograms/print_style.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Pretty-prints the histograms.xml file, alphabetizing tags, wrapping text 6 """Pretty-prints the histograms.xml file, alphabetizing tags, wrapping text
7 at 80 chars, enforcing standard attribute ordering, and standardizing 7 at 80 chars, enforcing standard attribute ordering, and standardizing
8 indentation. 8 indentation.
9 9
10 This is quite a bit more complicated than just calling tree.toprettyxml(); 10 This is quite a bit more complicated than just calling tree.toprettyxml();
(...skipping 22 matching lines...) Expand all
33 # and the value is a pair of the tag name of the children we want to sort, 33 # and the value is a pair of the tag name of the children we want to sort,
34 # and a key function that maps each child node to the desired sort key. 34 # and a key function that maps each child node to the desired sort key.
35 ALPHABETIZATION_RULES = { 35 ALPHABETIZATION_RULES = {
36 'histograms': ('histogram', lambda n: n.attributes['name'].value.lower()), 36 'histograms': ('histogram', lambda n: n.attributes['name'].value.lower()),
37 'enums': ('enum', lambda n: n.attributes['name'].value.lower()), 37 'enums': ('enum', lambda n: n.attributes['name'].value.lower()),
38 'enum': ('int', lambda n: int(n.attributes['value'].value)), 38 'enum': ('int', lambda n: int(n.attributes['value'].value)),
39 'histogram_suffixes_list': ( 39 'histogram_suffixes_list': (
40 'histogram_suffixes', lambda n: n.attributes['name'].value.lower()), 40 'histogram_suffixes', lambda n: n.attributes['name'].value.lower()),
41 'histogram_suffixes': ('affected-histogram', 41 'histogram_suffixes': ('affected-histogram',
42 lambda n: n.attributes['name'].value.lower()), 42 lambda n: n.attributes['name'].value.lower()),
43 # TODO(yiyaoliu): Remove fieldtrial related pieces when it is not used.
44 'fieldtrials': ('fieldtrial', lambda n: n.attributes['name'].value.lower()),
45 'fieldtrial': ('affected-histogram',
46 lambda n: n.attributes['name'].value.lower()),
47 } 43 }
48 44
49 45
50 class Error(Exception): 46 class Error(Exception):
51 pass 47 pass
52 48
53 49
54 def unsafeAppendChild(parent, child): 50 def unsafeAppendChild(parent, child):
55 """Append child to parent's list of children, ignoring the possibility that it 51 """Append child to parent's list of children, ignoring the possibility that it
56 is already in another node's childNodes list. Requires that the previous 52 is already in another node's childNodes list. Requires that the previous
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 logging.info('Creating backup file %s' % histograms_backup_filename) 169 logging.info('Creating backup file %s' % histograms_backup_filename)
174 shutil.move(histograms_pathname, histograms_backup_pathname) 170 shutil.move(histograms_pathname, histograms_backup_pathname)
175 171
176 logging.info('Writing new %s file' % histograms_filename) 172 logging.info('Writing new %s file' % histograms_filename)
177 with open(histograms_pathname, 'wb') as f: 173 with open(histograms_pathname, 'wb') as f:
178 f.write(pretty) 174 f.write(pretty)
179 175
180 176
181 if __name__ == '__main__': 177 if __name__ == '__main__':
182 main() 178 main()
OLDNEW
« no previous file with comments | « tools/metrics/histograms/extract_histograms.py ('k') | tools/metrics/histograms/print_style.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698