equal
deleted
inserted
replaced
85 value = None |
85 value = None |
86 key = keys[i] |
86 key = keys[i] |
87 result[key] = value |
87 result[key] = value |
88 |
88 |
89 return result |
89 return result |
|
90 |
|
91 def rename(target, keys): |
|
92 """Returns a dict containing only the key/value pairs from keys |
|
93 |
|
94 The keys from target will be looked up in keys, and the corresponding |
|
95 value from keys will be used instead. If a key is not found, it is skipped. |
|
96 |
|
97 Args: |
|
98 target: the dictionary to filter |
|
99 keys: the fields to filter |
|
100 """ |
|
101 |
|
102 result = {} |
|
103 |
|
104 for key, value in target.iteritems(): |
|
105 if key in keys: |
|
106 new_key = keys[key] |
|
107 result[new_key] = value |
|
108 |
|
109 return result |