openmedialibrary/oml/oxflask/utils.py
2014-05-12 04:09:31 +02:00

8 lines
200 B
Python

def get_by_key(objects, key, value):
obj = filter(lambda o: o.get(key) == value, objects)
return obj and obj[0] or None
def get_by_id(objects, id):
return get_by_key(objects, 'id', id)