(
        self,
        method=False,
        class_method=False,
        signature=None,
        debug=None,
        converter_name="converter",
    )
return main_converter_callable
Compiles a function which act according to the conversion
        definition.

        Args:
          debug (bool): If `True`, prints the generated code (formats with
            black if available). By default: None
          signature (str): Defines the signature of the function to be
            compiled.  `data_` argument is what going to be used as the input.
            e.g. ``signature="self, dt, data_, **kwargs"``
          method (bool): `True` is a shortcut for: ``signature="self, data_"``
          class_method (bool): `True` is a shortcut for:
            ``signature="cls, data_"``
          converter_name (str): prefix of the name of the function to be
            compiled

        Returns:
          The compiled function
Compiles a function which act according to the conversion
        definition.
Compiles a function which act according to the conversion definition .
def gen_converter(
        self,
        method=False,
        class_method=False,
        signature=None,
        debug=None,
        converter_name="converter",
    ) -> _ConverterCallable:
        """Compiles a function which act according to the conversion
        definition.

        Args:
          debug (bool): If `True`, prints the generated code (formats with
            black if available). By default: None
          signature (str): Defines the signature of the function to be
            compiled.  `data_` argument is what going to be used as the input.
            e.g. ``signature="self, dt, data_, **kwargs"``
          method (bool): `True` is a shortcut for: ``signature="self, data_"``
          class_method (bool): `True` is a shortcut for:
            ``signature="cls, data_"``
          converter_name (str): prefix of the name of the function to be
            compiled

        Returns:
          The compiled function
        """
        # signature should contain "data_" argument
        initial_code_input = "data_"
        debug = debug or (self.contents & self.ContentTypes.BREAKPOINT)
        ctx = self._init_ctx(debug=debug)

        converter_callable_cls = CodeGenerationOptionsCtx.get_option_value(
            "converter_callable_cls"
        )
        main_converter_callable = converter_callable_cls(debug=debug, ctx=ctx)
        ctx["__main_converter_callable"] = main_converter_callable

        if signature:
            signature_words = _pattern_word.findall(signature)
            missing_args = set(
                _pattern_word.findall(
                    self.get_args_def_code(exclude_labels=True)
                )
            ) - set(signature_words)
            if missing_args:
                raise ConversionException(
                    "bad signature, missing args", missing_args
                )
        else:
            if method and class_method:
                raise ConversionException(
                    "choose either method or a class_method"
                )
            signature = (
                ("self, " if method else "")
                + ("cls, " if class_method else "")
                + (initial_code_input)
                + (
                    self.get_args_def_code(
                        as_kwargs=True,
                        exclude_cls_self=True,
                        exclude_labels=True,
                    )
                )
            )

        code = Code()
        converter_name = self.gen_name(converter_name, ctx, self)
        code.add_line(f"def {converter_name}({signature}):", 1)
        code.add_line("global labels_", 0)
        code.add_line(
            "return {}".format(
                self.gen_code_and_update_ctx(initial_code_input, ctx)
            ),
            0,
        )
        main_converter = self._code_to_converter(
            converter_name=converter_name,
            code=code.to_string(base_indent_level=0),
            ctx=ctx,
        )
        main_converter_callable.set_main_converter(main_converter)
        del ctx[self.PREFIXED_HASH_TO_NAME]
        del ctx[self.GENERATED_NAMES]
        return main_converter_callable
def gen_converter ( self , method = False , class_method = False , signature = None , debug = None , converter_name = "converter" , ) -> _ConverterCallable : # signature should contain "data_" argument initial_code_input = "data_" debug = debug or ( self . contents & self . ContentTypes . BREAKPOINT ) ctx = self . _init_ctx ( debug = debug ) converter_callable_cls = CodeGenerationOptionsCtx . get_option_value ( "converter_callable_cls" ) main_converter_callable = converter_callable_cls ( debug = debug , ctx = ctx ) ctx [ "__main_converter_callable" ] = main_converter_callable if signature : signature_words = _pattern_word . findall ( signature ) missing_args = set ( _pattern_word . findall ( self . get_args_def_code ( exclude_labels = True ) ) ) - set ( signature_words ) if missing_args : raise ConversionException ( "bad signature, missing args" , missing_args ) else : if method and class_method : raise ConversionException ( "choose either method or a class_method" ) signature = ( ( "self, " if method else "" ) + ( "cls, " if class_method else "" ) + ( initial_code_input ) + ( self . get_args_def_code ( as_kwargs = True , exclude_cls_self = True , exclude_labels = True , ) ) ) code = Code ( ) converter_name = self . gen_name ( converter_name , ctx , self ) code . add_line ( f"def {converter_name}({signature}):" , 1 ) code . add_line ( "global labels_" , 0 ) code . add_line ( "return {}" . format ( self . gen_code_and_update_ctx ( initial_code_input , ctx ) ) , 0 , ) main_converter = self . _code_to_converter ( converter_name = converter_name , code = code . to_string ( base_indent_level = 0 ) , ctx = ctx , ) main_converter_callable . set_main_converter ( main_converter ) del ctx [ self . PREFIXED_HASH_TO_NAME ] del ctx [ self . GENERATED_NAMES ] return main_converter_callable