
    Le?                     N   d Z ddlZddlZddlZddlmZ 	 ddlZddlZn%# e$ r  ed            ej	                     Y nw xY w	 ddl
mZmZmZ n# e$ r ddlmZmZmZ Y nw xY wddlmZ  e             e             e            gZd	 Zdd
ZdZdZedk    r e             dS 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                     t          t          j                  dk     r"t          d           t          j                     t          j        dt          t          t                    } | 
                    ddt          dd	           | 
                    d
dt          dd	           |                                 }|j        r5t          t          |j        d                   t          j                   d S |j        d}n|j        }t"          j                            t(                    \  }}t"          j                            t"          j                            dd|                    }t/          ||           d S )Nr   z;For help with the holoviews command run:

holoviews --help
	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argsexamples_dircurdir_r   s         6lib/python3.11/site-packages/holoviews/util/command.pymainr1   $   sc   
38}}qNOOO


$+5I1<,24 4 4F
 js!L  N N N ,6H K  M M M D} 	/t}Q/00szBBBBBB (/LL0L7==**qwrw||Dv>>??l......    c                    |t                                           }| r| nt          j        d         } t	          |           5 }t          j        |t
          j                  }t          j	                    }|D ]}|
                    |           |                    |          \  }}|cd d d            S # 1 swxY w Y   d S )Nr   )_PREPROCESSORScopyr   r   opennbformatread
NO_CONVERT	nbconvertPythonExporterregister_preprocessorfrom_notebook_node)filenamepreprocessorsfnbexporterpreprocessorsourcemetas           r0   r$   r$   B   s    &++--#4xx!H	h 1]1h122+--) 	9 	9L**<888822266                 s   A&B44B8;B8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   r:   r7   ImportErrorr   r   ipython.preprocessorsr   r   r   holoviews.ipython.preprocessors r	   r4   r1   r$   r   r   __name__ r2   r0   <module>rN      s     				 



 ) ) ) ) ) )OOOO   	E
]^^^CHJJJJJ          
                     $$&&(<(<(>(>@T@T@V@VW/ / /<
 
 
 
 zDFFFFF s!    A A
A A"!A"