

def keyslice_pairs(pairs, include=None, omit=None, rename=None, key=None):
    "Filter (key, value) pairs by key and return a subset.\n\n    :param pairs: an iterable of ``(key, value)`` pairs (2-tuples).\n\n    :param include: optional, a sequence of key values.  If supplied, only\n        pairs whose key is a member of this sequence will be returned.\n\n    :param omit: optional, a sequence of key values. If supplied, all pairs\n        will be returned, save those whose key is a member of this sequence.\n\n    :param rename: optional, a mapping or sequence of 2-tuples specifying a\n        key-to-key translation.  A pair whose key has been renamed by this\n        translation will always be emitted, regardless of *include* or *omit*\n        rules.  The mapping will be converted to a dict internally, and keys\n        must be hashable.\n\n    :param key: optional, a function of one argument that is used to extract a\n        comparison key from the first item of each pair.  Similar to the\n        ``key`` parameter to Python's ``sort`` and ``sorted``.  Useful for\n        transforming unicode keys to bytestrings with ```key=str``, adding or\n        removing prefixes en masse, etc.\n\n    :returns: yields ``(key, value)`` pairs.\n\n    "
    if (omit and omit):
        raise TypeError('received include and omit, specify only one')
    include = (set(include) if include else False)
    omit = (set(omit) if omit else False)
    rename = (dict(to_pairs(rename)) if rename else False)
    keyfunc = key
    del key
    for (key, value) in pairs:
        if keyfunc:
            key = keyfunc(key)
        if (rename and (key in rename)):
            (yield (rename[key], value))
            continue
        if include:
            if (key not in include):
                continue
        elif omit:
            if (key in omit):
                continue
        (yield (key, value))

dataset/ETHPy150Open jek/flatland/flatland/util/base.py keyslice_pairs/VarMisuse@30/489 `include`->`omit`