Revision 330
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/util.py | ||
---|---|---|
12 | 12 |
while func(iter_.curr()): iter_.next() |
13 | 13 |
except StopIteration: pass # nothing after the matching elements |
14 | 14 |
|
15 |
def rename_key(dict_, orig, new): |
|
16 |
try: dict_[new] = dict_.pop(orig) |
|
17 |
except KeyError: pass |
|
15 |
def rename_key(dict_, orig, new): dict_[new] = dict_.pop(orig) |
lib/sql.py | ||
---|---|---|
139 | 139 |
def connect(db_config): |
140 | 140 |
db_config = db_config.copy() # don't modify input! |
141 | 141 |
module, mappings = db_engines[db_config.pop('engine')] |
142 |
for orig, new in mappings.iteritems(): util.rename_key(db_config, orig, new) |
|
142 |
for orig, new in mappings.iteritems(): |
|
143 |
try: util.rename_key(db_config, orig, new) |
|
144 |
except KeyError: pass |
|
143 | 145 |
return __import__(module).connect(**db_config) |
Also available in: Unified diff
util.py: Changed rename_key() not to suppress KeyError, since some callers might want to assert that a key exists