
     hi%                         d dl mZ d dlmZmZ d dlmZ ej                  d        Zej                  d        Z	ej                  d        Z
d Zd Zd	 Zd
 Zd Zy)    )	is_darwin)loggerget_hook_config)isolatedc                  p    ddl } t        j                  | j                  d      }t	        |t
              r|S y)a  
    Return the configured default matplotlib backend name, if available as matplotlib.rcParams['backend'] (or overridden
    by MPLBACKEND environment variable. If the value of matplotlib.rcParams['backend'] corresponds to the auto-sentinel
    object, returns None
    r   Nbackend)
matplotlibdict__getitem__rcParams
isinstancestr)r	   vals     VC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/hooks/hook-matplotlib.backends.py_get_configured_default_backendr      s3      

:..	
:C#s
    c                  6    ddl } | j                  j                  S )zA
    Returns the names of all available matplotlib backends.
    r   N)r	   rcsetupall_backends)r	   s    r   _list_available_mpl_backendsr   !   s    
 ***r   c                     t        |        y)zy
    Attempts to import the given module name (matplotlib backend module).

    Exceptions are propagated to caller.
    N)
__import__)module_names    r   _check_mpl_backend_importabler   *   s     {r   c                     ddl m}m} h  |d       |d      }g } ||       j                         D ]F  }|D ]?  \  }}t	        |      dvst        |d   t              s'||v s,|j                  |d          A H |S )z
    Recursively scan the bytecode for occurrences of matplotlib.use() or mpl.use() calls with const arguments, and
    collect those arguments into list of used matplotlib backend names.
    r   )	any_aliasrecursive_function_callszmatplotlib.usezmpl.use>         )PyInstaller.depend.bytecoder   r   valueslenr   r   append)cor   r   mpl_use_namesbackendscallsnameargss           r   (_recursive_scan_code_objects_for_mpl_user*   5   s     P	#	$	9	M
 H)"-446 ) 	)JD$ 4y&ja#.F}$Q(	)) Or   c                 T    | j                  d      r| dd S d| j                          S )z
    Converts matplotlib backend name to its corresponding module name.

    Equivalent to matplotlib.cbook._backend_module_name().
    z	module://	   Nzmatplotlib.backends.backend_)
startswithlower)r(   s    r   _backend_module_namer/   P   s.     {#ABx)$**,88r   c                 b   | j                   j                  }|j                  d      }g }|j                         D ]/  \  }}t	        |      }|st        j                  d||       ||z  }1 t        t        |            }|rd}t        j                  d||       |S t               }|rt        j                  d|       |gS g d}	t        rdg|	z   }	t        j                  d|	       |	D ]  }
	 t        |
      }t        |       |
gc S  t        j                  d	       d
gS # t        $ r Y Cw xY w)z
    Returns a list of automatically-discovered matplotlib backends in use, or the name of the default matplotlib
    backend. Implements the 'auto' backend selection method.
    r	   zMDiscovered Matplotlib backend(s) via `matplotlib.use()` call in module %r: %rzDhttps://pyinstaller.org/en/stable/hooks-config.html#matplotlib-hooksa  The following Matplotlib backends were discovered by scanning for `matplotlib.use()` calls: %r. If your backend of choice is not in this list, either add a `matplotlib.use()` call to your code, or configure the backend collection via hook options (see: %s).z/Found configured default matplotlib backend: %s)QtAggQt5AggGtk4AggGtk3AggTkAggWxAggMacOSXzTTrying determine the default backend as first importable candidate from the list: %rzONone of the backend candidates could be imported; falling back to headless Agg!Agg)analysisgraphget_code_usingitemsr*   r   infosortedsetr   r   r/   r   	Exception)hook_apimodulegraphmpl_code_objsused_backendsr(   r$   co_backendsHOOK_CONFIG_DOCSdefault_backend
candidates	candidater   s               r   _autodetect_used_backendsrJ   [   sT    ##))K..|<MM!'') )b>rBKK_aegr [(M) 3}-.MaABOQa	

  67OEW   MJZ*,

KKfhrs 		.y9K)+6 { KKab7N  		s   .D""	D.-D.c                 v   t               }t        j                  d|       g }ddh}t        s|ddhz  }|D ][  }||v rt        j                  d|       	 t	        |      }t        |       t        j                  d|       |j                  |       ] |S # t        $ r t        j                  d|       Y w xY w)	zn
    Returns a list of all importable matplotlib backends. Implements the 'all' backend selection method.
    z%All available matplotlib backends: %rQt4AggQt4CairoCocoaAggr7   z!  Matplotlib backend %r: excludedz4  Matplotlib backend %r: ignored due to import errorz  Matplotlib backend %r: added)r   r   r=   r   r/   r   r@   r#   )rA   backend_namesimportable_backendsexclude_backendsbackend_namer   s         r    _collect_all_importable_backendsrS      s    
 12M
KK7G  !*-
 Z22 & 1++KK;\J	.|<K)+6 	4lC""<01    	KKNP\]	s   BB87B8c                    t        | dd      }|d}|dk(  r!t        j                  d       t        |       }nh|dk(  r!t        j                  d       t	        |       }nBt        j                  d       t        |t              r|g}nt        |t              sJ d       |}t        t        |            }t        j                  d	|       |D cg c]  }t        |       }} | j                  |  y c c}w )
Nr	   r&   autozIMatplotlib backend selection method: automatic discovery of used backendsallzJMatplotlib backend selection method: collection of all importable backendsz:Matplotlib backend selection method: user-provided name(s)z@User-provided backend name(s) must be either a string or a list!z Selected matplotlib backends: %r)r   r   r=   rJ   rS   r   r   listr>   r?   r/   add_imports)rA   backends_methodrO   r   module_namess        r   hookr[      s    %hjIO  & _`1(;	E	!`a8BPQos+,-Mot4x6xx4+M 3}-.M
KK2MB BOOg(1OLOH,' Ps   C2N)PyInstaller.compatr   PyInstaller.utils.hooksr   r   PyInstallerr   decorater   r   r   r*   r/   rJ   rS   r[    r   r   <module>ra      sz    ) ;   
  
+ + 
 69@F%P(r   