B
    âÖÓY™  ã               @   sx   d Z ddlmZ ddlmZmZ ddlmZ G dd„ deeƒƒZG dd„ deƒZ	d	a
d
d„ ZG dd„ deƒZdd„ Zd	S )z!Frontend class representing a UX.é    )Úabsolute_import)ÚABCMetaÚabstractmethod)Úwith_metaclassc               @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zed
d„ ƒZ	edd„ ƒZ
dS )ÚFrontendz-A UX (CLI, GUI, etc.) for project operations.c             C   s   d| _ d| _dS )zConstruct a Frontend.Ú N)Ú	_info_bufÚ
_error_buf)Úself© r   ú8lib/python3.7/site-packages/anaconda_project/frontend.pyÚ__init__   s    zFrontend.__init__c             C   s\   || }|  d¡\}}}x>|dkrV| d¡r8|d d… }||ƒ |}|  d¡\}}}qW |S )NÚ
r   úéÿÿÿÿ)Ú	partitionÚendswith)r
   ÚdataZbufZline_handlerÚstartÚsepÚendr   r   r   Ú_partial   s    

zFrontend._partialc             C   s   |   || j| j¡| _dS )a  Log only part of an info-level line.

        The default implementation buffers this until a line separator
        and then passes the entire line to info().
        Subtypes can override this if they want to print output
        immediately as it arrives.
        N)r   r   Úinfo)r
   r   r   r   r   Úpartial_info)   s    zFrontend.partial_infoc             C   s   |   || j| j¡| _dS )a  Log only part of an error-level line.

        The default implementation buffers this until a line separator
        and then passes the entire line to error().
        Subtypes can override this if they want to print output
        immediately as it arrives.
        N)r   r	   Úerror)r
   r   r   r   r   Úpartial_error3   s    zFrontend.partial_errorc             C   s   dS )zLog an info-level message.Nr   )r
   Úmessager   r   r   r   =   s    zFrontend.infoc             C   s   dS )zËLog an error-level message.

        A rule of thumb is that if a function also returns a
        ``Status``, this message should also be appended to the
        ``errors`` field on that status.
        Nr   )r
   r   r   r   r   r   B   s    zFrontend.errorN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r      s   

r   c                   s@   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Z‡  Z	S )ÚNullFrontendz$A frontend that doesn't do anything.c                s   t t| ƒ ¡  dS )zConstruct a null frontend.N)Úsuperr!   r   )r
   )Ú	__class__r   r   r   U   s    zNullFrontend.__init__c             C   s   dS )zPart of a log message.Nr   )r
   r   r   r   r   r   Y   s    zNullFrontend.partial_infoc             C   s   dS )zPart of an error message.Nr   )r
   r   r   r   r   r   ]   s    zNullFrontend.partial_errorc             C   s   dS )zLog an info-level message.Nr   )r
   r   r   r   r   r   a   s    zNullFrontend.infoc             C   s   dS )zLog an error-level message.Nr   )r
   r   r   r   r   r   e   s    zNullFrontend.error)
r   r   r   r    r   r   r   r   r   Ú__classcell__r   r   )r#   r   r!   R   s   r!   Nc               C   s   t d krtƒ a t S )N)Ú_singleton_null_frontendr!   r   r   r   r   Ú_null_frontendm   s    r&   c                   s4   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Z‡  ZS )	Ú_ErrorRecordingFrontendProxyc                s   t t| ƒ ¡  g | _|| _d S )N)r"   r'   r   Ú_errorsÚ
underlying)r
   r)   )r#   r   r   r   u   s    z%_ErrorRecordingFrontendProxy.__init__c             C   s   | j  |¡ dS )zLog an info-level message.N)r)   r   )r
   r   r   r   r   r   z   s    z!_ErrorRecordingFrontendProxy.infoc             C   s   | j  |¡ | j |¡ dS )zLog an error-level message.N)r(   Úappendr)   r   )r
   r   r   r   r   r   ~   s    z"_ErrorRecordingFrontendProxy.errorc             C   s   | j }g | _ |S )N)r(   )r
   Úresultr   r   r   Ú
pop_errorsƒ   s    z'_ErrorRecordingFrontendProxy.pop_errors)r   r   r   r   r   r   r,   r$   r   r   )r#   r   r'   t   s   r'   c             C   s   t | ƒS )N)r'   )Zfrontendr   r   r   Ú_new_error_recorder‰   s    r-   )r    Z
__future__r   Úabcr   r   Z#anaconda_project.internal.metaclassr   r   r!   r%   r&   r'   r-   r   r   r   r   Ú<module>   s   B