def get_dict_repr()

in azurefunctions-extensions-base/azurefunctions/extensions/base/utils.py [0:0]


    def get_dict_repr(binding, input_types):
        """Build a dictionary of a particular binding. The keys are camel
        cased binding field names defined in `init_params` list and
        :class:`Binding` class. \n
        This method is invoked in function :meth:`get_raw_bindings` of class
        :class:`Function` to generate json dict for each binding.

        :return: Dictionary representation of the binding. Dict representation
        of the binding in the format:
        ((binding type, pytype), deferred bindings enabled)
        """
        params = list(dict.fromkeys(getattr(binding, "init_params", [])))
        binding_info = {}
        for p in params:
            if p not in Binding.EXCLUDED_INIT_PARAMS:
                binding._dict[to_camel_case(p)] = getattr(binding, p, None)

        if input_types.get(binding.name) is not None:
            pytype = input_types.get(binding.name).pytype
        else:
            pytype = None
        # Adding flag to signal to the host to send MBD object
        # 1. check if the binding is a supported type (blob, blobTrigger)
        # 2. check if the binding is an input binding
        # 3. check if the defined type is an SdkType
        if (
            binding.type in meta._ConverterMeta._bindings
            and binding.direction == 0
            and meta._ConverterMeta.check_supported_type(pytype)
        ):
            binding._dict["properties"] = {"SupportsDeferredBinding": True}
            binding_info = {binding.name: {pytype: "True"}}
        # if it isn't, we set the flag to false
        else:
            binding._dict["properties"] = {"SupportsDeferredBinding": False}
            binding_info = {binding.name: {pytype: "False"}}

        return binding._dict, binding_info