Chromium Code Reviews| Index: gm/rebaseline_server/utils.py |
| diff --git a/gm/rebaseline_server/utils.py b/gm/rebaseline_server/utils.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..327d286cf1b463a1c50fb36d7fcea49a0a1165c7 |
| --- /dev/null |
| +++ b/gm/rebaseline_server/utils.py |
| @@ -0,0 +1,28 @@ |
| +#!/usr/bin/python |
| + |
| +""" |
| +Copyright 2014 Google Inc. |
| + |
| +Use of this source code is governed by a BSD-style license that can be |
| +found in the LICENSE file. |
|
borenet
2014/05/08 12:40:18
I've been copy/pasting the same header, which read
epoger
2014/05/08 15:04:35
The most recent directive I have on what the copyr
|
| + |
| +Misc utilities for use throughout rebaseline_server code. |
| +""" |
| + |
| +def unzip_dict(input_dict): |
| + """Splits a dictionary into two lists (keys and values), such that the indexes |
| + within the lists can be used to connect key and value. |
|
borenet
2014/05/08 12:40:18
It seems like this should be a built-in function.
epoger
2014/05/08 15:04:35
Right, no guarantee of consistent ordering. Also
|
| + |
| + For this input: |
| + {K3:V3, K1:V1, K2:V2} |
| + |
| + It would return: |
| + [K1,K2,K3], [V1,V2,V3] |
| + """ |
| + keys = [] |
| + values = [] |
| + for key in sorted(input_dict.keys()): |
| + value = input_dict[key] |
| + keys.append(key) |
| + values.append(value) |
| + return keys, values |