root/scripts/lib/util.py @ 133
1 |
# Useful functions and classes
|
---|---|
2 |
|
3 |
def skip(iter_, func): |
4 |
# Advance iter while func is True
|
5 |
try: |
6 |
while func(iter_.curr()): iter_.next() |
7 |
except StopIteration: pass # nothing after the matching elements |
8 |
|
9 |
def rename_key(dict_, orig, new): |
10 |
try: dict_[new] = dict_.pop(orig) |
11 |
except KeyError: pass |