
    \e                     F    d Z ddlZddlZd Zd Zd Zd Zd
dZd
dZd	 Z	y)z0
Import related utilities and helper functions.
    Nc           
          | j                  d      \  }}}t        |       	 t        t        j                  |   |      S # t
        $ r5 t        d|dt        j                  t        j                          d      w xY w)zYReturns a class from a string including module and class.

    .. versionadded:: 0.3
    .zClass z cannot be found ())

rpartition
__import__getattrsysmodulesAttributeErrorImportError	tracebackformat_exceptionexc_info)
import_strmod_str_sep	class_strs       8/usr/lib/python3/dist-packages/oslo_utils/importutils.pyimport_classr      s|    
  *44S9GT9wIs{{7+Y77 I$$55s||~FH I 	IIs	   ? >A=c                 $     t        |       |i |S )zLImport a class and return an instance of it.

    .. versionadded:: 0.3
    )r   )r   argskwargss      r   import_objectr   '   s    
 $<
#T4V44    c                 l    | d|}	 t        |      } ||i |S # t        $ r t        |      }Y w xY w)a  Tries to import object from default namespace.

    Imports a class and return an instance of it, first by trying
    to find the class in a default namespace, then failing back to
    a full path if not found in the default namespace.

    .. versionadded:: 0.3

    .. versionchanged:: 2.6
       Don't capture :exc:`ImportError` when instanciating the object, only
       when importing the object class.
    r   )r   r   )
name_spacer   r   r   import_valueclss         r   import_object_nsr   /   sJ     )*5L'<(   ':&'s    33c                 >    t        |        t        j                  |    S )z0Import a module.

    .. versionadded:: 0.3
    )r   r	   r
   )r   s    r   import_moduler!   D   s    
 z;;z""r   c                 t    dd|z  v rt        d      | d|}|rdj                  ||f      }t        |      S )aK  Import a versioned module in format {module}.v{version][.{submodule}].

    :param module: the module name.
    :param version: the version number.
    :param submodule: the submodule name.
    :raises ValueError: For any invalid input.

    .. versionadded:: 0.3

    .. versionchanged:: 3.17
       Added *module* parameter.
    r   z%sz2Parameter version shouldn't include character '.'.z.v)
ValueErrorjoinr!   )moduleversion	submodule
module_strs       r   import_versioned_moduler)   M   sG     dWnMNN#W-JXXz956
$$r   c                 <    	 t        |       S # t        $ r |cY S w xY w)z6Try to import a module and if it fails return default.)r!   r   )r   defaults     r   
try_importr,   d   s&    Z(( s   
 c                 h    | f|z   D ]  }t        |      }|s|c S  t        dt        |      z        )a  Try to import a module from a list of modules.

    :param modules: A list of modules to try and import
    :returns: The first module found that can be imported
    :raises ImportError: If no modules can be imported from list

    .. versionadded:: 3.8
    z-Unable to import any modules from the list %s)r,   r   str)r%   r
   module_nameimported_modules       r   
import_anyr1   l   sK     y7* #$[1""#
 E'l# $ $r   )N)
__doc__r	   r   r   r   r   r!   r)   r,   r1    r   r   <module>r4      s6      I5 *#%.$r   