OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS 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 datetime | 6 import datetime |
7 import multiprocessing | 7 import multiprocessing |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 value: Value to write with the key. | 85 value: Value to write with the key. |
86 key: The variable key to update. (Default: PORTAGE_BINHOST) | 86 key: The variable key to update. (Default: PORTAGE_BINHOST) |
87 """ | 87 """ |
88 file_fh = open(filename) | 88 file_fh = open(filename) |
89 file_lines = [] | 89 file_lines = [] |
90 found = False | 90 found = False |
91 for line in file_fh: | 91 for line in file_fh: |
92 # Strip newlines from end of line. We already add newlines below. | 92 # Strip newlines from end of line. We already add newlines below. |
93 line = line.rstrip("\n") | 93 line = line.rstrip("\n") |
94 | 94 |
95 if '=' not in line: | 95 if len(line.split('=')) != 2: |
96 # Skip any line without an equal in it and just write it out. | 96 # Skip any line that doesn't fit key=val. |
97 file_lines.append(line) | 97 file_lines.append(line) |
98 continue | 98 continue |
99 | 99 |
100 file_var, file_val = line.split('=') | 100 file_var, file_val = line.split('=') |
101 keyval_str = '%(key)s=%(value)s' | 101 keyval_str = '%(key)s=%(value)s' |
102 if file_var == key: | 102 if file_var == key: |
103 found = True | 103 found = True |
104 print 'Updating %s=%s to %s="%s"' % (file_var, file_val, key, value) | 104 print 'Updating %s=%s to %s="%s"' % (file_var, file_val, key, value) |
105 value = '"%s"' % value | 105 value = '"%s"' % value |
106 file_lines.append(keyval_str % {'key': key, 'value': value}) | 106 file_lines.append(keyval_str % {'key': key, 'value': value}) |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 options.binhost_base_url, git_sync=options.git_sync) | 486 options.binhost_base_url, git_sync=options.git_sync) |
487 | 487 |
488 if options.board: | 488 if options.board: |
489 UploadPrebuilt(options.build_path, options.upload, version, | 489 UploadPrebuilt(options.build_path, options.upload, version, |
490 options.binhost_base_url, board=options.board, | 490 options.binhost_base_url, board=options.board, |
491 git_sync=options.git_sync) | 491 git_sync=options.git_sync) |
492 | 492 |
493 | 493 |
494 if __name__ == '__main__': | 494 if __name__ == '__main__': |
495 main() | 495 main() |
OLD | NEW |