| OLD | NEW |
| 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 Loading... |
| 33 | 33 |
| 34 UNIT_REWRITES = { | 34 UNIT_REWRITES = { |
| 35 'microsecond': 'microseconds', | 35 'microsecond': 'microseconds', |
| 36 'us': 'microseconds', | 36 'us': 'microseconds', |
| 37 'millisecond': 'ms', | 37 'millisecond': 'ms', |
| 38 'milliseconds': 'ms', | 38 'milliseconds': 'ms', |
| 39 'kb': 'KB', | 39 'kb': 'KB', |
| 40 'kB': 'KB', | 40 'kB': 'KB', |
| 41 'kilobytes': 'KB', | 41 'kilobytes': 'KB', |
| 42 'kbits/s': 'kbps', | 42 'kbits/s': 'kbps', |
| 43 'mb': 'MB', |
| 44 'mB': 'MB', |
| 45 'megabytes': 'MB', |
| 46 'mbits/s': 'mbps', |
| 43 'percent': '%', | 47 'percent': '%', |
| 44 'Percent': '%', | 48 'Percent': '%', |
| 45 'percentage': '%', | 49 'percentage': '%', |
| 46 } | 50 } |
| 47 | 51 |
| 48 | 52 |
| 49 def canonicalizeUnits(tree): | 53 def canonicalizeUnits(tree): |
| 50 """Canonicalize the spelling of certain units in histograms.""" | 54 """Canonicalize the spelling of certain units in histograms.""" |
| 51 histograms = tree.getElementsByTagName('histogram') | 55 histograms = tree.getElementsByTagName('histogram') |
| 52 for histogram in histograms: | 56 for histogram in histograms: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 79 return print_style.GetPrintStyle().PrettyPrintXml(tree) | 83 return print_style.GetPrintStyle().PrettyPrintXml(tree) |
| 80 | 84 |
| 81 | 85 |
| 82 def main(): | 86 def main(): |
| 83 presubmit_util.DoPresubmitMain(sys.argv, 'histograms.xml', | 87 presubmit_util.DoPresubmitMain(sys.argv, 'histograms.xml', |
| 84 'histograms.before.pretty-print.xml', | 88 'histograms.before.pretty-print.xml', |
| 85 'pretty_print.py', PrettyPrint) | 89 'pretty_print.py', PrettyPrint) |
| 86 | 90 |
| 87 if __name__ == '__main__': | 91 if __name__ == '__main__': |
| 88 main() | 92 main() |
| OLD | NEW |