a
    Df?                     @   s   d Z ddlZddlZddlZddlmZ zddlZddlZW n" ey^   ed e	  Y n0 zddl
mZmZmZ W n& ey   ddlmZmZmZ Y n0 ddlmZ e e e gZd	d
 ZdddZdZdZedkre  dS )za
python -m holoviews.util.command Conversion_Example.ipynb
OR
holoviews Conversion_Example.ipynb
    N)RawTextHelpFormatterzQnbformat, nbconvert and ipython need to be installed to use the holoviews command   )OptsMagicProcessorOutputMagicProcessorStripMagicsProcessor   )examplesc                  C   s   t tjdk rtd t  tjdttt	d} | j
ddtddd	 | j
d
dtddd	 |  }|jrtt|jd tjd nJ|jd u rd}n|j}tjt\}}tjtjdd|}t||d d S )Nr   z;For help with the holoviews command run:

holoviews --help
Z	holoviews)progformatter_classdescriptionepilogz
--notebooknotebookr   z1The Jupyter notebook to convert to Python syntax.)metavartypenargshelpz--install-examplesinstall_examples?z,Install examples to the specified directory.r   )filezholoviews-examplesz..)pathroot)lensysargvprintexitargparseArgumentParserr   r   r   add_argumentstr
parse_argsr   export_to_pythonstdoutr   osr   split__file__abspathjoinr   )parserargsZexamples_dircurdir_r    r,   c/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/holoviews/util/command.pymain$   s0    
r.   c                 C   s   |d u rt  }| r| ntjd } t| L}t|tj}t	 }|D ]}|
| qF||\}}|W  d    S 1 s|0    Y  d S )Nr   )_PREPROCESSORScopyr   r   opennbformatreadZ
NO_CONVERT	nbconvertZPythonExporterZregister_preprocessorZfrom_notebook_node)filenameZpreprocessorsfnbZexporterpreprocessorsourcemetar,   r,   r-   r!   B   s    
r!   a  
Command line interface for holoviews.

This utility allows conversion of notebooks containing the HoloViews
%opts, %%opts, %output and %%output magics to regular Python
syntax. This is useful for turning Jupyter notebooks using HoloViews
into Bokeh applications that can be served with:

bokeh server --show converted_notebook.py

The holoviews command supports the following options:
z
Example usage
-------------

$ holoviews ./examples/demos/matplotlib/area_chart.ipynb

The converted syntax is then output to standard output where you can
direct it to a Python file of your choosing.
__main__)NN)__doc__r   r#   r   r   r4   r2   ImportErrorr   r   Zipython.preprocessorsr   r   r   Zholoviews.ipython.preprocessors r   r/   r.   r!   r   r   __name__r,   r,   r,   r-   <module>   s,   
