def call()

in elasticapm/instrumentation/packages/psycopg2.py [0:0]


    def call(self, module, method, wrapped, instance, args, kwargs):
        if "conn_or_curs" in kwargs and hasattr(kwargs["conn_or_curs"], "__wrapped__"):
            kwargs["conn_or_curs"] = kwargs["conn_or_curs"].__wrapped__
        # register_type takes the connection as second argument
        elif len(args) == 2 and hasattr(args[1], "__wrapped__"):
            args = (args[0], args[1].__wrapped__)
        # register_json takes the connection as first argument, and can have
        # several more arguments
        elif method == "register_json":
            if args and hasattr(args[0], "__wrapped__"):
                args = (args[0].__wrapped__,) + args[1:]

        elif method == "encrypt_password":
            # connection/cursor is either 3rd argument, or "scope" keyword argument
            if len(args) >= 3 and hasattr(args[2], "__wrapped__"):
                args = args[:2] + (args[2].__wrapped__,) + args[3:]
            elif "scope" in kwargs and hasattr(kwargs["scope"], "__wrapped__"):
                kwargs["scope"] = kwargs["scope"].__wrapped__

        return wrapped(*args, **kwargs)