def pick(keys: Sequence[str], doc: Dict) -> Dict: """Picks the provided keys from the dictionary. Example pick(["a", "b"], {"a": 1, "b": 2, "c": 3}) # => {"a": 1, "b": 2} """ if not _.isIterable(keys): return None if not isinstance(doc, dict): return None return {k: doc.get(k, None) for k in keys}
def getValues(doc, keys): if not _.isIterable(keys): return None return _.map(lambda k: get(doc, k), keys)