L i ddlmZddlZddlZddlZddlmZmZmZm Z ddl m Z ddl m Z ddlmZddlmZerdd lmZ d dd Z dd Z dd Z d dd Zy)) annotationsN)IO TYPE_CHECKINGAnyLiteral)using_vegafusion)deprecated_warn)data_transformers)spec_to_mimebundle)Pathct|ttjfrAtj|j ||5}|j |dddy|j |y#1swYyxYw)zRWrite content to fp, whether fp is a string, a pathlib Path or a file-like object.modeencodingN) isinstancestrpathlibr openwrite)fpcontentrrfs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/altair/utils/save.pywrite_file_or_filenamersi"sGLL)* \\"  " "x " @ A GGG      s A44A=c|\t|ttjfr/tj|jj d}n d}t ||dk7r|rtjdd|S)z1Inspect the format argument in the save function..zGmust specify file format: ['png', 'svg', 'pdf', 'html', 'json', 'vega']htmlz-inline argument ignored for non HTML formats.r ) stacklevel) rrrr suffixlstrip ValueErrorwarningswarn)formatrinlinemsgs rset_inspect_format_argumentr( sq~ b3 - .\\"%,,33C8F@ S/ ! F ERST Mc|(d|vr|d}nd|vr|djdd}nd}|dk7rd|d}t||dk(r| d}t||S) z/Inspect the mode argument in the save function.rz$schema/z vega-litezmode must be 'vega-lite', not ''zmust specify vega-lite version)splitr")r embed_optionsspecvegalite_versionr's rset_inspect_mode_argumentr24s | ] " (D $  ?((-b1DD {24&:o {/7.o Kr)c    jddx} r tddxsi jddt d     fd }t r%t j 5|dddyt jd 5t j 5|ddddddy#1swYyxYw#1swYxYw#1swYyxYw) a Save a chart to file in a variety of formats. Supported formats are [json, html, png, svg, pdf] Parameters ---------- chart : alt.Chart the chart instance to save fp : string filename, pathlib.Path or file-like object file to which to write the chart. format : string (optional) the format to write: one of ['json', 'html', 'png', 'svg', 'pdf']. If not specified, the format will be determined from the filename. mode : string (optional) Must be 'vega-lite'. If not specified, then infer the mode from the '$schema' property of the spec, or the ``opt`` dictionary. If it's not specified in either of those places, then use 'vega-lite'. vega_version : string (optional) For html output, the version of vega.js to use vegalite_version : string (optional) For html output, the version of vegalite.js to use vegaembed_version : string (optional) For html output, the version of vegaembed.js to use embed_options : dict (optional) The vegaEmbed options dictionary. Default is {} (See https://github.com/vega/vega-embed for details) json_kwds : dict (optional) Additional keyword arguments are passed to the output method associated with the specified format. scale_factor : float (optional) scale_factor to use to change size/resolution of png or svg output engine: string {'vl-convert'} the conversion engine to use for 'png', 'svg', and 'pdf' formats inline: bool (optional) If False (default), the required JavaScript libraries are loaded from a CDN location in the resulting html file. If True, the required JavaScript libraries are inlined into the resulting html file so that it will work without an internet connection. The vl-convert-python package is required if True. **kwargs : additional kwargs passed to spec_to_mimebundle. webdriverNzThe webdriver argument is not relevant for the new vl-convert engine which replaced altair_saver. The argument will be removed in a future release.z5.0.0)versionrzutf-8c jddi}txsi|} dk(r&tj|fi}t |d y dk(r. rdd <t d| |d }t |d d y d k(r*t d| | d }t |dddy dvr?t d| | d } dk(rt |ddyt |dd yd d}t |)N pre_transformF)contextjsonwrrr&template)r0r%r vega_versionr1vegaembed_versionr/ json_kwdsz text/htmlpng) r0r%rr<r1r=r/ scale_factorenginerz image/pngwb)r>pdfsvgvegarCzapplication/pdfz image/svg+xmlzUnsupported format: 'r-)to_dictr2r9dumpsrr r")r0 inner_mode json_specmb_htmlmb_pngmb_anyr'chartr/rrAr%rr&r>kwargsrr@r<r=r1s r perform_savezsave..perform_saves}}ou%=}>. -%2t-=  V  4595I "2ysX N v %-z"( )!1"3+#  G #GK(sX u_' )!1"3+)  F #2vay'=D I - -' )!1"3+)  F&r62C+D4P&/cH*&3CS/ !r)default)returnNone)popr getr(rr disable_max_rowsenable)rNrr<r=r%rr1r/r>r@rAr&rO_rPrs````````````` @rsaverYNst JJ{D ))q) @ RIzz*g.H (V ">">"@ / / 1  N   % %i 0 2C2T2T2V  N         s0C,C2C& C2C#&C/ +C22C;)r:N) rstr | Path | IOrz str | bytesrrr str | NonerRrS)r%r[rrZr&boolrRr) rLiteral['vega-lite'] | Noner/dict[str, Any]r0r^r1r[rRzLiteral['vega-lite'])NNNNNr NF)rrZr<r[r=r[r%z3Literal['json', 'html', 'png', 'svg', 'pdf'] | Nonerr]r1r[r/ dict | Noner>r_r@floatrAzLiteral['vl-convert'] | Noner&r\rRrS) __future__rr9rr#typingrrrraltair.utils._vegafusion_dataraltair.utils.deprecationr altair.vegalite.v5.datar mimebundler r rr(r2rYrFr)rrgsa" 22:45*           +59( %! !   >CG(,#'!%!+/RRR" R @ R & R!RRRR )R R Rr)