OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 import fileinput | 6 import fileinput |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 There are two kinds of graphs to be updated (one is for numbers and the | 38 There are two kinds of graphs to be updated (one is for numbers and the |
39 other is for passing rates). | 39 other is for passing rates). |
40 | 40 |
41 Args: | 41 Args: |
42 datetime_string: a datetime string (e.g., '2008,1,1,13,45,00)' | 42 datetime_string: a datetime string (e.g., '2008,1,1,13,45,00)' |
43 data_map: a dictionary containing 'whole', 'skip' , 'nonskip', | 43 data_map: a dictionary containing 'whole', 'skip' , 'nonskip', |
44 'passingrate' as its keys and (number, tile, text) string tuples | 44 'passingrate' as its keys and (number, tile, text) string tuples |
45 as values for graph annotation. | 45 as values for graph annotation. |
46 """ | 46 """ |
47 joined_str = '' | 47 joined_str = '' |
48 # For a date format in GViz, month is shifted (e.g., '2008,1,1' means | |
dennis_jeffrey
2011/09/01 00:29:13
Maybe pick a slightly different example than "2008
imasaki1
2011/09/01 03:08:23
Done.
| |
49 # Feb. 1st, 2008). | |
50 str_list = datetime_string.split(',') | |
dennis_jeffrey
2011/09/01 00:29:13
Just to clarify: if we have 'Jan. 1, 2008', does t
imasaki1
2011/09/01 03:08:23
The input string for 'Jan. 1, 2008' is '2008,0,1'
dennis_jeffrey
2011/09/01 16:56:42
Ok, if that is true, then won't line 51 below subt
imasaki1
2011/09/03 19:35:13
Sorry I was not clear.
Input string ranges from (
| |
51 str_list[1] = str(int(str_list[1])-1) # month | |
52 datetime_string = ','.join(str_list) | |
48 for key in ['whole', 'skip', 'nonskip']: | 53 for key in ['whole', 'skip', 'nonskip']: |
49 joined_str += ','.join(data_map[key]) + ',' | 54 joined_str += ','.join(data_map[key]) + ',' |
50 new_line_for_numbers = ' [new Date(%s),%s],\n' % (datetime_string, | 55 new_line_for_numbers = ' [new Date(%s),%s],\n' % (datetime_string, |
51 joined_str) | 56 joined_str) |
52 new_line_for_numbers += ' %s\n' % ( | 57 new_line_for_numbers += ' %s\n' % ( |
53 LINE_INSERT_POINT_FOR_NUMBERS) | 58 LINE_INSERT_POINT_FOR_NUMBERS) |
54 self._ReplaceLine(LINE_INSERT_POINT_FOR_NUMBERS, new_line_for_numbers) | 59 self._ReplaceLine(LINE_INSERT_POINT_FOR_NUMBERS, new_line_for_numbers) |
55 | 60 |
56 joined_str = '%s,%s,%s' % ( | 61 joined_str = '%s,%s,%s' % ( |
57 data_map['passingrate'][0], data_map['nonskip'][1], | 62 data_map['passingrate'][0], data_map['nonskip'][1], |
(...skipping 11 matching lines...) Expand all Loading... | |
69 Args: | 74 Args: |
70 search_exp: search expression to find a line to be replaced. | 75 search_exp: search expression to find a line to be replaced. |
71 replace_line: the new line. | 76 replace_line: the new line. |
72 """ | 77 """ |
73 replaced = False | 78 replaced = False |
74 for line in fileinput.input(self._location, inplace=1): | 79 for line in fileinput.input(self._location, inplace=1): |
75 if search_exp in line: | 80 if search_exp in line: |
76 replaced = True | 81 replaced = True |
77 line = replace_line | 82 line = replace_line |
78 sys.stdout.write(line) | 83 sys.stdout.write(line) |
OLD | NEW |