def _standard_listen_example(dispatch_descriptor, sample_target, fn):
    example_kw_arg = _indent(
        "\n".join(
            "%(arg)s = kw['%(arg)s']" % {"arg": arg}
            for arg in dispatch_descriptor.arg_names[0:2]
        ),
        "    ")
    if dispatch_descriptor.legacy_signatures:
        current_since = max(since for since, args, conv
                            in dispatch_descriptor.legacy_signatures)
    else:
        current_since = None
    text = (
        "from sqlalchemy import event\n\n"
        "# standard decorator style%(current_since)s\n"
        "@event.listens_for(%(sample_target)s, '%(event_name)s')\n"
        "def receive_%(event_name)s("
        "%(named_event_arguments)s%(has_kw_arguments)s):\n"
        "    \"listen for the '%(event_name)s' event\"\n"
        "\n    # ... (event handling logic) ...\n"
    )

    if len(dispatch_descriptor.arg_names) > 3:
        text += (

            "\n# named argument style (new in 0.9)\n"
            "@event.listens_for("
            "%(sample_target)s, '%(event_name)s', named=True)\n"
            "def receive_%(event_name)s(**kw):\n"
            "    \"listen for the '%(event_name)s' event\"\n"
            "%(example_kw_arg)s\n"
            "\n    # ... (event handling logic) ...\n"
        )

    text %= {
        "current_since": " (arguments as of %s)" %
        current_since if current_since else "",
        "event_name": fn.__name__,
        "has_kw_arguments": ", **kw" if dispatch_descriptor.has_kw else "",
        "named_event_arguments": ", ".join(dispatch_descriptor.arg_names),
        "example_kw_arg": example_kw_arg,
        "sample_target": sample_target
    }
    return text
dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/sqlalchemy/event/legacy.py/_standard_listen_example/original