
    0-Ph                     `   d Z ddlZddlZddlmZ ddlZddlZddlmZ ddl	m
Z
 dgZdgd	fd
Zd ZdgfdZd Zedk    rm eej                  dk    rej        d         dk    r e             dS  eej                  dk    rej        d         dk    r e             dS  ed          dS )z<
Console scripts and associated helper methods for imageio.
    N)path   )plugins)util	freeimageallFc                    |                      d          rt          } |                                  t          d                    d                    |                                |rt          j                    }nd}| D ]Z}|t          vr$d                    |          }t          |          t          t          |          }|                    |           [dS )a  Download binary dependencies of plugins

    This is a convenience method for downloading the binaries
    (e.g. for freeimage) from the imageio-binaries
    repository.

    Parameters
    ----------
    plugin_names: list
        A list of imageio plugin names. If it contains "all", all
        binary dependencies are downloaded.
    package_dir: bool
        If set to `True`, the binaries will be downloaded to the
        `resources` directory of the imageio package instead of
        to the users application data directory. Note that this
        might require administrative rights if imageio is installed
        in a system directory.
    r   zAscertaining binaries for: {}., N-Plugin {} not registered for binary download!)	directory)countPLUGINS_WITH_BINARIESsortprintformatjoinr   resource_package_dir	Exceptiongetattrr   download)plugin_namespackage_dirr   plgmsgmods         P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/imageio/__main__.pydownload_binr      s    & %   -,	
*
1
1$))L2I2I
J
JKKK  -//			 * *+++AHHMMCC.. gs##y))))* *    c                  (   d} d}d}d}t          j        | |t           j                  }|                    dt          dd|	           |                    d
ddd|           |                                }t          |j        |j                   dS )z+Argument-parsing wrapper for `download_bin`z#Download plugin binary dependencieszcPlugin name for which to download the binary. If no argument is given, all binaries are downloaded.zDownload the binaries to the package directory (default is the users application data directory). This might require administrative rights.zFexamples:
  imageio_download_bin all
  imageio_download_bin freeimage
descriptionepilogformatter_classplugin*r   typenargsdefaulthelpz--package-dirr   
store_trueF)destactionr)   r*   )r   r   N)	argparseArgumentParserRawDescriptionHelpFormatteradd_argumentstr
parse_argsr   r$   r   )r!   phelpdhelpexample_textparserargss         r   download_bin_mainr9   @   s    7K	B 

	6 
	/ 
 $ <  F
 s#u5QQQ
     Ddkt7GHHHHHHr   c                    |                      d          rt          } t          d                    d                    |                                t          j                    }| D ]/}|t          vr$d                    |          }t          |          0g }|D ]m}t          j	        |          D ]V}|| v rPt          j        ||          }	 t          j        |           1# t          $ r |                    |           Y Rw xY wWn|r<d                    |          }d                    |          dz   }	t          |	          dS )	zRemove binary dependencies of plugins

    This is a convenience method that removes all binaries
    dependencies for plugins downloaded by imageio.

    Notes
    -----
    It only makes sense to use this method if the binaries
    are corrupt.
    r   zRemoving binaries for: {}.r
   r   ,z-These plugins files could not be removed: {}
z9Make sure they are not used by any program and try again.N)r   r   r   r   r   r   resource_dirsr   oslistdiropshutilrmtreeappend)
r   rdirsr   r   not_removedrdrsubplgdirnrsmsg2s
             r   
remove_binrJ   b   s    %   -,	
&
-
-dii.E.E
F
FGGG  E ! !+++AHHMMCC..  , K / /JrNN 	/ 	/D|##T**/M&))))  / / /&&v...../	 $	/  hh{##<CCCHHIJ 	 oo s   C""DDc                      d} d}d}t          j        | |t           j                  }|                    dt          dd|           |                                }t          |j        	           d
S )z)Argument-parsing wrapper for `remove_bin`z!Remove plugin binary dependenciesz^Plugin name for which to remove the binary. If no argument is given, all binaries are removed.zBexamples:
  imageio_remove_bin all
  imageio_remove_bin freeimage
r    r$   r%   r   r&   )r   N)r.   r/   r0   r1   r2   r3   rJ   r$   )r!   r4   r6   r7   r8   s        r   remove_bin_mainrL      s    5K	? 

	- 
 $ <  F
 s#u5QQQDDK((((((r   __main__r   rJ   zInvalid use of the imageio CLI)__doc__r.   r=   r   r?   r@   sys r   corer   r   r   r9   rJ   rL   __name__lenargvRuntimeError r   r   <module>rW      sl     				        



             %   %g5 )* )* )* )*XI I ID #G ( ( ( (V) ) ), z
s38}}qSXa[N::	SX		sx{l::l;<<< r   