U
    Ph                      @  sX   d Z ddlmZ ddlZddlZddlZddlZe Zi Z	ddgZ
dd Zdd ZdS )zI
This module is written for configurable workflow, not currently in use.
    )annotationsNaliasresolve_namec                    s    fdd}|S )z
    Stores the decorated function or class in the global aliases table under the given names and as the `__aliases__`
    member of the decorated object. This new member will contain all alias names declared for that object.
    c              
     s<    D ]}t  | t|< W 5 Q R X qt| ddt  | _| S )N__aliases__ )
alias_lockGlobalAliasesgetattrtupler   )objnnamesr   H/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/utils/aliases.py_outer"   s
    zalias.<locals>._outerr   )r   r   r   r   r   r      s    
c           
   
     s  t  t }W 5 Q R X  tkr.|dkr.t|dkrd kr dd\}}zt|}t||d}W n4 tk
r } zt	d|d|W 5 d}~X Y nX |dkrt	d|d|d|dkr fddt
tj D }t|d	krft|dkrXttd fd
d|D }t|dkrPdd |D }d|d d}	t	|	t
|}t|d	  }|dkrt	d d|S )a  
    Search for the declaration (function or class) with the given name. This will first search the list of aliases to
    see if it was declared with this aliased name, then search treating `name` as a fully qualified name, then search
    the loaded modules for one having a declaration with the given name. If no declaration is found, raise ValueError.

    Raises:
        ValueError: When the module is not found.
        ValueError: When the module does not have the specified member.
        ValueError: When multiple modules with the declaration name are found.
        ValueError: When no module with the specified member is found.

    N.   zModule z not found.z does not have member c                   s   g | ]}t | d r|qS )N)r	   .0mnamer   r   
<listcomp>V   s      z resolve_name.<locals>.<listcomp>r   c                   s   h | ]}t t| qS r   )inspect	getmoduler	   r   r   r   r   	<setcomp>Z   s     zresolve_name.<locals>.<setcomp>c                 S  s   g | ]
}|j qS r   )__name__r   r   r   r   r   ]   s     zMultiple modules (z) with declaration name z  found, resolution is ambiguous.zNo module with member z found.)r   r   getAssertionErrorrsplit	importlibimport_moduler	   ModuleNotFoundError
ValueErrorlistsysmodulesvalueslensetfilter)
r   r   modnameZdeclnamemodZnot_found_errmodsZ	foundmodsmodnamesmsgr   r   r   r   /   s6    
$

)__doc__
__future__r   r    r   r%   	threadingRLockr   r   __all__r   r   r   r   r   r   <module>   s   