+L i nddlmZddlZddlZddlZdejj _dZdZdZ y))globNsphinx_gallery_pngc tjj|d}tt tjj |d}tt tjj |d}|d}t }t} t||D]\} } | | vs | t| z} t|} tjj| ddz} |j| tj| | tj| | t||dS)a<Scrape Plotly figures for galleries of examples using sphinx-gallery. Examples should use ``plotly.io.show()`` to display the figure with the custom sphinx_gallery renderer. Since the sphinx_gallery renderer generates both html and static png files, we simply crawl these files and give them the appropriate path. Parameters ---------- block : tuple A tuple containing the (label, content, line_number) of the block. block_vars : dict Dict of block variables. gallery_conf : dict Contains the configuration of Sphinx-Gallery **kwargs : dict Additional keyword arguments to pass to :meth:`~matplotlib.figure.Figure.savefig`, e.g. ``format='svg'``. The ``format`` kwarg in particular is used to set the file extension of the output file (currently only 'png' and 'svg' are supported). Returns ------- rst : str The ReSTructuredText that will be rendered to HTML containing the images. Notes ----- Add this function to the image scrapers src_filez*.pngz*.htmlimage_path_iteratorrz.htmlsrc_dir)ospathdirnamesortedrjoinlistsetzipnextsplitextappendshutilmove figure_rst)block block_vars gallery_confkwargs examples_dirpngshtmlsr image_namesseenhtmlpngthis_image_path_pngthis_image_path_htmls [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/plotly/io/_sg_scraper.pyplotly_sg_scraperr% sD77??:j#9:L $rww||L':; E$%:;&K 5D%4 c d? CH D"&':"; #%77#3#34G#H#Kg#U   3 4 KK0 1 KK2 34 k< #: ;;cf|Dcgc]O}tjj||jtjdj dQ}}d}|s|S|d}tjj dtjj|}t|z}|Scc}w)aGenerate RST for a list of PNG filenames. Depending on whether we have one or more figures, we use a single rst call to 'image' or a horizontal list. Parameters ---------- figure_list : list List of strings of the figures' absolute paths. sources_dir : str absolute path of Sphinx documentation sources Returns ------- images_rst : str rst code to embed the images in the document /rimages) r r relpathreplaceseplstripr basename SINGLE_HTML) figure_list sources_dir figure_path figure_paths images_rst figure_names r$rrAs*'   [199"&&#FMMcRLJ q/K'',,x)9)9+)FGK{*J sAB.z .. raw:: html :file: %s ) rr rplotlyio renderersdefaultr%rr0r&r$r<s8 2 1