(
        self,
        profile_template: dict,
        target: dict = {}
    )
return target
Generate a target configuration from profile_template and user input.
Generate a target configuration from profile_template and user input.
Generate a target configuration from profile_template and user input .
def generate_target_from_input(
        self,
        profile_template: dict,
        target: dict = {}
    ) -> dict:
        """Generate a target configuration from profile_template and user input.
        """
        profile_template_local = copy.deepcopy(profile_template)
        for key, value in profile_template_local.items():
            if key.startswith("_choose"):
                choice_type = key[8:].replace("_", " ")
                option_list = list(value.keys())
                prompt_msg = "\n".join([
                    f"[{n+1}] {v}" for n, v in enumerate(option_list)
                ]) + f"\nDesired {choice_type} option (enter a number)"
                numeric_choice = click.prompt(prompt_msg, type=click.INT)
                choice = option_list[numeric_choice - 1]
                # Complete the chosen option's values in a recursive call
                target = self.generate_target_from_input(
                    profile_template_local[key][choice], target
                )
            else:
                if key.startswith("_fixed"):
                    # _fixed prefixed keys are not presented to the user
                    target[key[7:]] = value
                else:
                    hide_input = value.get("hide_input", False)
                    default = value.get("default", None)
                    hint = value.get("hint", None)
                    type = click_type_mapping[value.get("type", None)]
                    text = key + (f" ({hint})" if hint else "")
                    target[key] = click.prompt(
                        text,
                        default=default,
                        hide_input=hide_input,
                        type=type
                    )
        return target
def generate_target_from_input ( self , profile_template : dict , target : dict = { } ) -> dict : profile_template_local = copy . deepcopy ( profile_template ) for key , value in profile_template_local . items ( ) : if key . startswith ( "_choose" ) : choice_type = key [ 8 : ] . replace ( "_" , " " ) option_list = list ( value . keys ( ) ) prompt_msg = "\n" . join ( [ f"[{n+1}] {v}" for n , v in enumerate ( option_list ) ] ) + f"\nDesired {choice_type} option (enter a number)" numeric_choice = click . prompt ( prompt_msg , type = click . INT ) choice = option_list [ numeric_choice - 1 ] # Complete the chosen option's values in a recursive call target = self . generate_target_from_input ( profile_template_local [ key ] [ choice ] , target ) else : if key . startswith ( "_fixed" ) : # _fixed prefixed keys are not presented to the user target [ key [ 7 : ] ] = value else : hide_input = value . get ( "hide_input" , False ) default = value . get ( "default" , None ) hint = value . get ( "hint" , None ) type = click_type_mapping [ value . get ( "type" , None ) ] text = key + ( f" ({hint})" if hint else "" ) target [ key ] = click . prompt ( text , default = default , hide_input = hide_input , type = type ) return target