예제 #1
0
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}
예제 #2
0
def getValues(doc, keys):
    if not _.isIterable(keys):
        return None
    return _.map(lambda k: get(doc, k), keys)