a
    õ£Be–  ã                   @   s$   d Z ddlmZ eedœdd„ZdS )z:
A simple utility to import something by its string name.
é    )ÚAny)ÚnameÚreturnc              
   C   sž   t | tƒstdt| ƒ ƒ‚|  dd¡}t|ƒdkrŽ|\}}t||gd�}zt||ƒ}W n2 tyˆ } zt	d| ƒ|‚W Y d}~n
d}~0 0 |S t|d ƒS dS )	a‰  Import and return ``bar`` given the string ``foo.bar``.

    Calling ``bar = import_item("foo.bar")`` is the functional equivalent of
    executing the code ``from foo import bar``.

    Parameters
    ----------
    name : string
        The fully qualified name of the module/package being imported.

    Returns
    -------
    mod : module object
        The module that was imported.
    z&import_item accepts strings, not '%s'.Ú.é   é   )ÚfromlistzNo module named %sNr   )
Ú
isinstanceÚstrÚ	TypeErrorÚtypeÚrsplitÚlenÚ
__import__ÚgetattrÚAttributeErrorÚImportError)r   ÚpartsÚpackageÚobjÚmoduleZpakÚe© r   ú_/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitlets/utils/importstring.pyÚimport_item	   s    
$r   N)Ú__doc__Útypingr   r
   r   r   r   r   r   Ú<module>   s   