

def show_chain(*chains, **kw):
    "Show a chain (or several chains) of object references.\n\n    Useful in combination with :func:`find_ref_chain` or\n    :func:`find_backref_chain`, e.g.\n\n        >>> show_chain(find_backref_chain(obj, is_proper_module))\n\n    You can specify if you want that chain traced backwards or forwards\n    by passing a ``backrefs`` keyword argument, e.g.\n\n        >>> show_chain(find_ref_chain(obj, is_proper_module),\n        ...            backrefs=False)\n\n    Ideally this shouldn't matter, but for some objects\n    :func:`gc.get_referrers` and :func:`gc.get_referents` are not perfectly\n    symmetrical.\n\n    You can specify ``highlight``, ``extra_info``, ``refcounts``,\n    ``shortnames``,``filename`` or ``output`` arguments like for\n    :func:`show_backrefs` or :func:`show_refs`.\n\n    .. versionadded:: 1.5\n\n    .. versionchanged:: 1.7\n       New parameter: ``backrefs``.\n\n    .. versionchanged:: 2.0\n       New parameter: ``output``.\n\n    "
    backrefs = kw.pop('backrefs', True)
    chains = [chain for chain in chains if chain]

    def in_chains(x, ids=set(map(id, itertools.chain(*chains)))):
        return (id(x) in ids)
    max_depth = (max(map(len, chains)) - 1)
    if backrefs:
        show_backrefs([chain[(- 1)] for chain in chains], max_depth=max_depth, filter=in_chains, **kw)
    else:
        show_refs([chain[0] for chain in chains], max_depth=max_depth, filter=in_chains, **kw)

dataset/ETHPy150Open Exa-Networks/exabgp/lib/exabgp/dep/objgraph.py show_chain/original