| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Common code for platforms.""" | 5 """Common code for platforms.""" |
| 6 | 6 |
| 7 | 7 |
| 8 def _safe_parse(content, split=': '): | 8 def _safe_parse(content, split=': '): |
| 9 """Safely parse a 'key: value' list of strings from a command.""" | 9 """Safely parse a 'key: value' list of strings from a command.""" |
| 10 values = {} | 10 values = {} |
| 11 for l in content.splitlines(): | 11 for l in content.splitlines(): |
| 12 if not l: | 12 if not l: |
| 13 continue | 13 continue |
| 14 parts = l.split(split, 2) | 14 parts = l.split(split, 2) |
| 15 if len(parts) != 2: | 15 if len(parts) != 2: |
| 16 continue | 16 continue |
| 17 values.setdefault( | 17 values.setdefault( |
| 18 parts[0].strip().decode('utf-8'), parts[1].decode('utf-8')) | 18 parts[0].strip().decode('utf-8'), parts[1].decode('utf-8')) |
| 19 return values | 19 return values |
| OLD | NEW |