
    cL                     j    d Z ddlZddlmZ ddlmZmZ  G d de          Z G d de          ZeZ	dS )	z#Plugins base classes and functions.    N)join)_ArgsTransformerProjectCommandc                       e Zd ZdZd Zd ZdS )ArgsTransformerTemplatezTemplate class for plugins args trasformers.

    Plugins args transformers should subclass it and redefine add_class
    to implement custom arguments mapping.
    c                     || _         dS )zConstruct an ArgTransformer for the given command.

        Args:
            command (ProjectCommand): command that maps to the ArgsTransformer
        N)command)selfr	   s     8lib/python3.11/site-packages/anaconda_project/plugins.py__init__z ArgsTransformerTemplate.__init__   s         c                      t          d          )a  Overwrite this method to add custom arguments transformation.

        It should forwarding the arguments that are custom to the
        specific command served by this trasformer (
            i.e., '--anaconda-project-host' --> 'host'
        )

        Inputs:
            - results [list(tuples)]: list of 2 element tuples (option, values):
                           * option (str): name of the option
                            * values (lst(str)): list of the values passed
                                        for the option
            - args [list]: list of the args already passed in

        Returns:
            (list) list of the transformed args (that should include args)
        znot implemented)RuntimeError)r
   resultsargss      r   add_argsz ArgsTransformerTemplate.add_args   s    $ ,---r   N)__name__
__module____qualname____doc__r   r    r   r   r   r      s<         
  . . . . .r   r   c                   P     e Zd ZdZdZdZ fdZed             ZddZ	ddZ
 xZS )CommandTemplatez+Represents a command from the project file.Nc                     t          t          |                               ||           |                     |           | _        dS )zConstruct a command with the given attributes.

        Args:
            name (str): name of the command
            attributes (dict): named attributes of the command
        )name
attributesN)superr   r   args_transformer_cls_args_transformer)r
   r   r   	__class__s      r   r   zCommandTemplate.__init__=   sD     	ot$$--4J-OOO!%!:!:4!@!@r   c                 N    t          t          j        d         d| j                  S )z1Full command path pointing to <conda prefix>/bin.CONDA_PREFIXbin)r   osenvironr	   )r
   s    r   command_with_conda_prefixz)CommandTemplate.command_with_conda_prefixG   s     BJ~.t|DDDr   c                 d    | j                             |          }|                     ||          S )z?Prepare extra args calling class _args_trasform.transform_args.)
extra_args)r   transform_argschoose_args_and_shellr
   r%   r(   s      r   _choose_args_and_shellz&CommandTemplate._choose_args_and_shellL   s1    +:::FF
))'j)IIIr   c                     t                      )z7Overwrite this method to implement custom plugin logic.)NotImplementedErrorr+   s      r   r*   z%CommandTemplate.choose_args_and_shellQ   s    !###r   )N)r   r   r   r   r   r	   r   propertyr&   r,   r*   __classcell__)r    s   @r   r   r   1   s        55  
 GA A A A A E E XEJ J J J
$ $ $ $ $ $ $ $r   r   )
r   r$   os.pathr   !anaconda_project.project_commandsr   r   r   r   ArgsTrasformerTemplater   r   r   <module>r4      s    * ) 				       P P P P P P P P .  .  .  .  ..  .  .  .F"$ "$ "$ "$ "$n "$ "$ "$L 1   r   