
    `f                     "   d Z ddlZddlZddlZddlmZ ddlmZmZ 	 ddl	m
Z
 n# e$ r	 ddlm
Z
 Y nw xY wddlmZ ej                            d          ZdZ G d	 d
e          Zd Zd Zed             ZddZddZddZd Zd Zd Zd ZdS )z;Utilities related to importing modules and symbols by name.    N)contextmanager)import_modulereload)entry_pointssymbol_by_nameMP_MAIN_FILE)
NotAPackagequalnameinstantiater   cwd_in_pathfind_moduleimport_from_cwdreload_from_cwdmodule_filegen_task_namec                       e Zd ZdZdS )r
   z8Raised when importing a package, but it's not a package.N)__name__
__module____qualname____doc__     F/var/www/html/env/lib/python3.11/site-packages/celery/utils/imports.pyr
   r
      s        BBBBr   r
   c                     t          | d          st          | d          r| j        } t          | dd          }d|vrd                    | j        |f          }|S )zReturn object name.r   	__class__r   N.)hasattrr   getattrjoinr   )objqs     r   r   r       sc    3
## [(A(A m^T**A
!||HHcna())Hr   c                 ,     t          |           |i |S )zNInstantiate class by name.

    See Also:
        :func:`symbol_by_name`.
    r   )nameargskwargss      r   r   r   *   s!      >$0000r   c               #     K   	 t          j                    } n# t          $ r d} Y nw xY w| sdV  dS | t          j        v rdV  dS t          j                            d|            	 | V  	 t          j                            |            dS # t          $ r Y dS w xY w# 	 t          j                            |            w # t          $ r Y w w xY wxY w)z9Context adding the current working directory to sys.path.Nr   )osgetcwdFileNotFoundErrorsyspathinsertremove
ValueError)cwds    r   r   r   3   s     ikk    	3	III$$$$$   $$$$   sN    '''B ,B 
BBC C ?C 
C
CCCc           	         |t           }t                      5  	  ||           cddd           S # t          $ r d| v r|                     d          }t	          |dd                   D ]h\  }}d                    |d|dz                      }	  ||          }n# t          $ r Y  n*w xY w	 |j         L# t          $ r t          |          w xY w w xY w# 1 swxY w Y   dS )z3Version of :func:`imp.find_module` supporting dots.Nr      )	r   r   ImportErrorsplit	enumerater    __path__AttributeErrorr
   )moduler,   imppartsipartpackagemparts           r   r   r   I   su   
{	  	3v;;         	 	 	 f}}S))(ss44 3 3GAt!hhuVa!eV}55G #G&    3) 3 3 3)'2223#	         s]   C
1ACBC
B+	'C*B+	+C/B76C7C	CCC Cc                 ~    |t           }t                      5   || |          cddd           S # 1 swxY w Y   dS )zImport module, temporarily including modules in the current directory.

    Modules located in the current directory has
    precedence over modules located in `sys.path`.
    N)r>   )r   r   )r9   r:   r>   s      r   r   r   d   s     {	 , ,s67+++, , , , , , , , , , , , , , , , , ,s   266c                 z    |t           }t                      5   ||           cddd           S # 1 swxY w Y   dS )z1Reload module (ensuring that CWD is in sys.path).N)r   r   )r9   reloaders     r   r   r   p   s    	    x                                   s   044c                 R    | j         }|                    d          r
|dd         n|S )z2Return the correct original file name of a module.z.pycNr2   )__file__endswith)r9   r$   s     r   r   r   x   s,    ?Df--749947r   c                 .   |pd}	 t           j        |         }n# t          $ r d}Y nw xY w| |j        }t          r|j        t          k    rd}|dk    r#| j        rd                    | j        |g          S d                    d ||fD                       S )z)Generate task name from name/module pair.__main__Nr   c              3      K   | ]}||V  	d S Nr   ).0ps     r   	<genexpr>z gen_task_name.<locals>.<genexpr>   s'      88!a8A888888r   )r+   modulesKeyErrorr   r	   rD   mainr    )appr$   module_namer9   s       r   r   r   ~   s    +K[)    o  	%FO|;;$Kj  SX xx4()))8888T2888888s    ((c              #   "  K   t           j        dk    rt          |           }nV	 t                                          | g           }n2# t          $ r% t                                          |           }Y nw xY w|D ]}|j        |j        fV  d S )N)   
   )group)r+   version_infor   getr8   selectr$   value)	namespace_entry_pointseps      r   load_extension_class_namesr]      s      
7""$9555	C(NN..y"==MM 	C 	C 	C(NN11	1BBMMM	C    grx   s   "A ,A76A7c           
   #      K   t          |           D ]V\  }}	 t          |          }||fV  # t          t          f$ r'}t	          j        d|  d|d|           Y d }~Od }~ww xY wd S )NzCannot load z extension z: )r]   r   r4   SyntaxErrorwarningswarn)rZ   r$   
class_nameclsexcs        r   load_extension_classesre      s      6yAA  j	 ,,C
 )OOOO	 [) 	N 	N 	NMLyLLZLLSLLN N N N N N N N	N s   .A&A!!A&)NNrI   )r   r(   r+   r`   
contextlibr   	importlibr   r   importlib.metadatar   r4   importlib_metadatakombu.utils.importsr   environrW   r	   __all__	Exceptionr
   r   r   r   r   r   r   r   r   r]   re   r   r   r   <module>rn      s   A A 				 



  % % % % % % + + + + + + + +0/////// 0 0 0////////0 / . . . . . z~~n--C C C C C) C C C  1 1 1   *   6	, 	, 	, 	,       8 8 89 9 9,	  	  	     s   % 33