
    89jK                         d dl Z d dlmZ d dl mZ d dlZd dlZd Zd Zed        Zd Z	 G d d	      Z
 G d
 de      Zy)    N)entry_points)cachec                  P    t         j                  j                  dd      } | dk(  ryy)z7Determine if dispatching has been disabled by the user.SKIMAGE_NO_DISPATCHINGF1T)osenvironget)no_dispatchings    V/media/conek/DATA/Code/OCR/venv/lib/python3.12/site-packages/skimage/util/_backends.pydispatching_disabledr      s%    ZZ^^$<eDN    c                 v   | j                   }dg}|D cg c]  }|j                  |      s| }}t        |      dk(  rP|j                  d      }t        |      dk  rd| j                   d}t	        |      dj                  |dd       }|S t        |      dk(  r|d   }|S | d	|}t	        |      c c}w )
zGet the name of the public module for a scikit-image function.

    This computes the name of the public submodule in which the function can
    be found.
    zskimage.filters.rankr   .   zexpected func.__module__=z% with more than 2 dot-delimited partsN   z& matches more than one sub-submodule: )
__module__
startswithlensplit
ValueErrorjoin)func	full_namesub_submodulesname
candidatespartsmsgpublic_names           r   public_api_moduler!      s     I --N#1P4Y5I5I$5O$PJP
:!$u:?.doo//TUCS/!hhuRay)  
ZA	 m  >znMo Qs
   B6B6c                      i } t        d      }t        d      }|D ]H  }d|i| |j                  <   	 ||j                     } |j                                | |j                     d<   J | S # t        $ r Y Xw xY w)z7List all installed backends and information about them.skimage_backends)groupskimage_backend_infosimplementationinfo)r   r   loadKeyError)backends	backends_backend_infosbackendr'   s        r   all_backendsr.   6   s     H#56I '>?M "2G!<	 .D-8TYY[]HW\\"6* O  		s   4A**	A65A6c                       j                   t               t               s
t               s S t	        j
                          fd       }|S )zMark a function as dispatchable.

    When a decorated function is called, the installed backends are
    searched for an implementation. If no backend implements the function
    then the scikit-image implementation is used.
    c            
      x   t        t                     D ]  }t               |   } d	 |d   j                  vr'|d   j                         } |j                   d	 g| i |}|sX|j                   d	       }t        j                  d d	 d| dt        d        || i |c S   | i |S )	N:r'   r&   z	Call to 'z' was dispatched to the 'z8' backend. Set SKIMAGE_NO_DISPATCHING=1 to disable this.r   )
stacklevel)	sortedr.   supported_functionsr(   can_hasget_implementationwarningswarnDispatchNotification)
argskwargsr   r-   backend_implwants_it	func_implr   func_module	func_names
          r   wrapperzdispatchable.<locals>.wrapperY   s    <>*  	)D"nT*G a	{+76?3V3VV"#3499;L ,|++-q,/37=H $77;-q8TUIMMK=) 5 !! %
 
 d-f--; 	)@ (((r   )__name__r!   r   r.   	functoolswraps)r   rA   r?   r@   s   ` @@r   dispatchablerE   I   sL     I#D)K
 \^__T%) %)N Nr   c                       e Zd ZdZd Zy)BackendInformationzInformation about a backend

    A backend that wants to provide additional information about itself
    should return an instance of this from its information entry point.
    c                     || _         y )N)r4   )selfr4   s     r   __init__zBackendInformation.__init__   s
    #6 r   N)rB   r   __qualname____doc__rJ    r   r   rG   rG      s    7r   rG   c                       e Zd ZdZy)r9   z?Notification issued when a function is dispatched to a backend.N)rB   r   rK   rL   rM   r   r   r9   r9      s    Ir   r9   )rC   importlib.metadatar   r   r   r7   r   r!   r.   rE   rG   RuntimeWarningr9   rM   r   r   <module>rQ      sO     +  	 "J  $8v7 7	> 	r   