B
    Tò†[×  ã               @   sŠ   d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZmZ e d¡Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ ZdS )zl
[Deprecation warning]
`anaconda notebook` is going to be deprecated
use `anaconda upload/download` instead
é    )Úunicode_literalsN)Úerrors)Úget_server_api)ÚUploaderÚ
DownloaderÚparseÚnotebook_urlÚhas_environmentzbinstar.notebookc             C   s6   d}| j dtj||td}| ¡ }t|ƒ t|ƒ d S )Nz3Interact with notebooks in your Anaconda repositoryÚnotebook)Úformatter_classÚhelpÚdescriptionÚepilog)Ú
add_parserÚargparseÚRawDescriptionHelpFormatterÚ__doc__Zadd_subparsersÚadd_upload_parserÚadd_download_parser)Ú
subparsersr   ÚparserZnb_subparsers© r   ú_lib/python3.7/site-packages/anaconda_client-1.7.2-py3.7.egg/binstar_client/commands/notebook.pyr      s    r   c             C   s¨   d}d}| j dtj|||d}| d¡}|jdddd	 |jd
ddd	 |jdddd	 |jdddd	 |jdddd	 |jdddd |jdddd |jtd d S )Nz-Upload a notebook to your Anaconda repositoryzs
    [Deprecation warning]
    `anaconda notebook` is going to be deprecated
    use `anaconda upload` instead
    Úupload)r   r   r   r   zmetadata optionsz-nz--namez'Notebook's name (will be parameterized))r   z-vz	--versionzNotebook's versionz-sz	--summaryzSet the summary of the notebookz-tz--thumbnailzNotebook's thumbnail imagez-uz--userz*User account, defaults to the current userz--forcez,Force a notebook upload regardless of errorsÚ
store_true)r   Úactionr
   zNotebook to uploadÚstore)Úmain)r   r   r   Zadd_argument_groupÚadd_argumentÚset_defaultsr   )r   r   r   r   Zmgroupr   r   r   r      s0    
r   c             C   sb   d}d}| j dtj|||d}|jdddd |jd	d
ddd |jddddd |jtd d S )Nz0Download notebooks from your Anaconda repositoryzu
    [Deprecation warning]
    `anaconda notebook` is going to be deprecated
    use `anaconda download` instead
    Údownload)r   r   r   r   Úhandlezuser/notebookr   )r   r   z-fz--forceZ	Overwriter   z-oz--outputzDownload asÚ.)r   Údefault)r   )r   r   r   r   r   r    )r   r   r   r   r   r   r   r   E   s(    r   c          
   C   s¸   t | j| jƒ}t|| j| j| j| j| j| j	d}yL|j
| jd}t d¡ t d¡ t d | j¡¡ t d t|ƒ¡¡ W n6 tjtfk
r² } zt t|ƒ¡ W d d }~X Y nX d S )N)ÚuserÚsummaryÚversionÚ	thumbnailÚname)Úforcez-`anaconda notebook` is going to be deprecatedzuse `anaconda upload` instead.z{} has been uploaded.z!You can visit your notebook at {})r   ÚtokenÚsiter   r
   r$   r%   r&   r'   r(   r   r)   ÚloggerÚwarningÚinfoÚformatr   r   ZBinstarErrorÚIOErrorÚerrorÚstr)ÚargsÚaserver_apiZuploaderZupload_infoÚer   r   r   r   g   s    

r   c          
   C   s  t | j| j| jƒ}t| jƒ\}}|p.| ¡ d }t|||ƒ}yˆ|| j| j	d}t
 d¡ t
 d¡ t
 d | j|d ¡¡ t|d ƒrÂt
 d |d ¡¡ t
 d¡ t
 d	 |d ¡¡ t
 d
¡ W n8 tjtjtfk
rü } zt
 |j¡ W d d }~X Y nX d S )NZlogin)Úoutputr)   z-`anaconda notebook` is going to be deprecatedz use `anaconda download` instead.z{} has been downloaded as {}.r   z{} has an environment embedded.zRun:z    conda env create {}z)To install the environment in your system)r   r*   r+   Z	log_levelr   r!   r$   r   r6   r)   r,   r-   r.   r/   r	   r   ZDestionationPathExistsZNotFoundÚOSErrorÚmsg)r3   r4   Zusernamer
   Z
downloaderZdownload_infoÚerrr   r   r   r    w   s     


r    )r   Z
__future__r   r   ZloggingZbinstar_clientr   Zbinstar_client.utilsr   Zbinstar_client.utils.notebookr   r   r   r   r	   Z	getLoggerr,   r   r   r   r   r    r   r   r   r   Ú<module>   s   
'"