U
    ꥡc)                     @   s   d dl mZ dddZdS )   )spec_to_htmlNc           	      K   s$  |dkrt d|dkrB|dkrB|dkr0t dd|d | iS |dkrzddl}W n$ tk
rz   t d	j|d
Y nX |j| |fd|i|S |dkrt| f||||d|}d|iS |dkr|dkst|dkrt d|dkrt dd|d | iS |dkrd| iS t ddS )a  Convert a vega/vega-lite specification to a mimebundle

    The mimebundle type is controlled by the ``format`` argument, which can be
    one of the following ['html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite']

    Parameters
    ----------
    spec : dict
        a dictionary representing a vega-lite plot spec
    format : string {'html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite'}
        the file format to be saved.
    mode : string {'vega', 'vega-lite'}
        The rendering mode.
    vega_version : string
        The version of vega.js to use
    vegaembed_version : string
        The version of vegaembed.js to use
    vegalite_version : string
        The version of vegalite.js to use. Only required if mode=='vega-lite'
    **kwargs :
        Additional arguments will be passed to the generating function

    Returns
    -------
    output : dict
        a mime-bundle representing the image

    Note
    ----
    The png, svg, pdf, and vega outputs require the altair_saver package
    to be installed.
    )vega	vega-litez)mode must be either 'vega' or 'vega-lite'r   NzMust specify vega_versionzapplication/vnd.vega.v{}+json    )ZpngsvgZpdfr   zqSaving charts in {fmt!r} format requires the altair_saver package: see http://github.com/altair-viz/altair_saver/)fmtmodehtml)r   vega_versionvegaembed_versionvegalite_versionz	text/htmlr   z&Cannot convert a vega spec to vegalitezMust specify vegalite_versionz!application/vnd.vegalite.v{}+jsonjsonzapplication/jsonzPformat must be one of ['html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite'])
ValueErrorformataltair_saverImportErrorrenderr   AssertionError)	specr   r   r
   r   r   kwargsr   r	    r   ;/tmp/pip-unpacked-wheel-y9_o96ar/altair/utils/mimebundle.pyspec_to_mimebundle   sP    )


r   )NNNN)r	   r   r   r   r   r   r   <module>   s
       