B
    Y%                 @   sP   d Z ddlZddlmZ ddlmZmZmZ G dd deZG dd deZ	dS )	z#Plugins base classes and functions.    N)join)_ArgsTransformerProjectCommand_http_specsc                   s(   e Zd ZdZ fddZdd Z  ZS )ArgsTrasformerTemplatezTemplate class for plugins args trasformers.

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

        Args:
            command (ProjectCommand): command that maps to the ArgsTransformer
        N)superr   __init__r   command)selfr	   )	__class__ 7lib/python3.7/site-packages/anaconda_project/plugins.pyr      s    zArgsTrasformerTemplate.__init__c             C   s   t ddS )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 implementedN)RuntimeError)r
   Zresultsargsr   r   r   add_args   s    zArgsTrasformerTemplate.add_args)__name__
__module____qualname____doc__r   r   __classcell__r   r   )r   r   r      s   	r   c                   sH   e Zd ZdZdZdZ fddZedd ZdddZ	dd	d
Z
  ZS )CommandTemplatez+Represents a command from the project file.Nc                s$   t t| j||d | | | _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)r   r   r   args_transformer_cls_args_transformer)r
   r   r   )r   r   r   r   ?   s    zCommandTemplate.__init__c             C   s   t tjd d| jS )z1Full command path pointing to <conda prefix>/bin.ZCONDA_PREFIXbin)r   osenvironr	   )r
   r   r   r   command_with_conda_prefixI   s    z)CommandTemplate.command_with_conda_prefixc             C   s   | j |}| j||dS )z?Prepare extra args calling class _args_trasform.transform_args.)
extra_args)r   Ztransform_argschoose_args_and_shell)r
   r   r   r   r   r   _choose_args_and_shellN   s    z&CommandTemplate._choose_args_and_shellc             C   s
   t  dS )z7Overwrite this method to implement custom plugin logic.N)NotImplementedError)r
   r   r   r   r   r   r    S   s    z%CommandTemplate.choose_args_and_shell)N)N)r   r   r   r   r   r	   r   propertyr   r!   r    r   r   r   )r   r   r   3   s   

r   )
r   r   os.pathr   Z!anaconda_project.project_commandsr   r   r   r   r   r   r   r   r   <module>   s
   %