
    -Ph                         d Z ddlmZ ddlmZ d Z G d d          Z G d d          Zd	 Z	 G d
 d          Z
 G d d          Z e
            Z e            Z e            Z e            Zd ZdS )z#Utility functions for doc building.    N)matplotlib_scraperc                 :    d| }di |d}|g| d         z   | d<   dS )z:Implement JupyterLite-specific modifications of notebooks.z JupyterLite-specific change for markdown)	cell_typemetadatasourcecellsN )notebook_contentnotebook_filenamer   markdown_cells       d/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx_gallery/tests/tinybuild/utils.pynotebook_modification_functionr      s=    C0ACCF","OOM!.2B72K KW    c                       e Zd ZdZd Zd ZdS )MatplotlibFormatScraperzFCalls Matplotlib scraper, passing required `format` kwarg for testing.c                     | j         j        S )N)	__class____name__selfs    r   __repr__z MatplotlibFormatScraper.__repr__   s    ~&&r   c                     t                      }t          j        |d                   dk    r|d         dk    rd|d<   n/t          j        |d                   dk    r|d         dk    rd|d<   t          |||fi |S )	zACall Matplotlib scraper with required `format` kwarg for testing.target_filezplot_svg.pybuilder_namelatexsvgformatzplot_webp.pywebp)dictopbasenamer   )r   block
block_varsgallery_confkwargss        r   __call__z MatplotlibFormatScraper.__call__   s    K
=122mCC^,77$F8K
=122nDD^,77%F8!%\LLVLLLr   Nr   
__module____qualname____doc__r   r'   r
   r   r   r   r      s=        PP' ' 'M M M M Mr   r   c                       e Zd ZdZd Zd ZdS )	ResetArgvzEProvide `reset_argv` callable returning required `sys.argv` for test.c                     dS )Nr-   r
   r   s    r   r   zResetArgv.__repr__(   s    {r   c                      d|d         v rdgS g S )zCReturn 'plot' arg if 'plot_command_line_args' example, for testing.zplot_command_line_args.pysrc_fileplotr
   )r   sphinx_gallery_confscript_varss      r   r'   zResetArgv.__call__+   s    &+j*AAA8OIr   Nr(   r
   r   r   r-   r-   %   s8        OO      r   r-   c                  V    dd l m} |                    d           t          d          )Nr   allzDzero-size array to reduction operation minimum which has no identity)matplotlib.pyplotpyplotclose
ValueError)argsr&   plts      r   _raiser<   3   s;    ######IIe
N  r   c                   $    e Zd ZdZd Zd Zd ZdS )MockScrapeProblemz6Used in 'reset_modules' to mock error during scraping.c                 *    ddl m} |j        | _        d S )Nr   colorConverter)matplotlib.colorsrA   to_rgba_orig)r   rA   s     r   __init__zMockScrapeProblem.__init__?   s"    444444#+


r   c                     dS )Nr>   r
   r   s    r   r   zMockScrapeProblem.__repr__D   s    ""r   c                 N    ddl m} d|v rt          |_        dS | j        |_        dS )z)Raise error for 'scraper_broken' example.r   r@   scraper_brokenN)rB   rA   r<   rC   rD   )r   r%   fnamerA   s       r   r'   zMockScrapeProblem.__call__G   s=    444444u$$%+N"""%)ZN"""r   N)r   r)   r*   r+   rE   r   r'   r
   r   r   r>   r>   <   sG        @@, , ,
# # #0 0 0 0 0r   r>   c                       e Zd ZdZd Zd ZdS )MockSortz9Fake sort used to test that mini-gallery sort is correct.c                     dS )NrK   r
   r   s    r   r   zMockSort.__repr__T   s    zr   c                     d|v rdS d|v rdS |S )z!Sort plot_sub* for one test case.subdir2r   subdir1   r
   )r   fs     r   r'   zMockSort.__call__W   s#    >>1>>1r   Nr(   r
   r   r   rK   rK   Q   s8        CC      r   rK   c                     | S )zSortkey that passes x.r
   )xs    r   noop_keyrT   f   s    Hr   )r+   os.pathpathr!   sphinx_gallery.scrapersr   r   r   r-   r<   r>   rK   mock_scrape_problemmatplotlib_format_scraper
reset_argv	mock_sortrT   r
   r   r   <module>r\      sG   ) )       6 6 6 6 6 6L L LM M M M M M M M,         0 0 0 0 0 0 0 0*        (')) 3355 Y[[
HJJ	    r   