o
    ›¨Êh*  ã                   @   sÈ   d 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	 ddl
mZ edƒZd	Zd
ZdZe	ded�ejƒZdZdd„ Zdd„ Zd"dd„Zdd„ Zdd„ Zdd„ Zd#dd„ZeeddƒZd$d d!„ZdS )%zWorker name utilities.é    N)Úpartial)ÚExchangeÚQueueé   )Úmemoize)Úsimple_formatzC.dq2z{hostname}.dq2ú@Úcelery)ÚCache)Úworker_directÚgethostnameÚnodenameÚanon_nodenameÚ	nodesplitÚdefault_nodenameÚnode_formatÚhost_formatc                 C   s"   t | tƒr| S ttj| d�t| ƒS )a5  Return the :class:`kombu.Queue` being a direct route to a worker.

    Arguments:
        hostname (str, ~kombu.Queue): The fully qualified node name of
            a worker (e.g., ``w1@example.com``).  If passed a
            :class:`kombu.Queue` instance it will simply return
            that instead.
    ©Úhostname)Ú
isinstancer   ÚWORKER_DIRECT_QUEUE_FORMATÚformatÚWORKER_DIRECT_EXCHANGEr   © r   úH/var/www/html/env/lib/python3.10/site-packages/celery/utils/nodenames.pyr      s   
	
ýr   c                 C   s   t  | |f¡S )z)Create node name from name/hostname pair.)ÚNODENAME_SEPÚjoin)Únamer   r   r   r   r   1   s   r   Úgenc                 C   s"   t d |tt ¡ ƒg¡| ptƒ ƒS )zsReturn the nodename for this process (not a worker).

    This is used for e.g. the origin task message field.
    Ú )r   r   ÚstrÚosÚgetpidr   )r   Úprefixr   r   r   r   6   s   ÿr   c                 C   s(   |   td¡}t|ƒdkrd|d fS |S )z,Split node name into tuple of name/hostname.r   Nr   )Úsplitr   Úlen)r   Úpartsr   r   r   r   ?   s   r   c                 C   s$   t | pdƒ\}}t|pt|ptƒ ƒS )z-Return the default nodename for this process.r   )r   r   ÚNODENAME_DEFAULTr   )r   r   Úhostr   r   r   r   G   s   r   c                 K   s(   t |ƒ\}}t| ||ptfd|i|¤ŽS )z(Format worker node name (name@host.com).Úp)r   r   r'   )Úsr   ÚextraÚ	shortnamer(   r   r   r   r   M   s   
ÿÿÿr   r   Ú0c                 C   s&   ddl m} |ƒ }|r| › |› �S |S )Nr   )Úcurrent_process_index)Úlogr.   )r#   Údefaultr.   Úindexr   r   r   Ú_fmt_process_indexT   s   r2   ú-c                 K   sH   |pt ƒ }| d¡\}}}|p|}t|||ttdœfi |¤Ž}t| |ƒS )zFormat host %x abbreviations.Ú.)ÚhÚnÚdÚiÚI)r   Ú	partitionÚdictr2   Ú_fmt_process_index_with_prefixr   )r*   r(   r   r+   ÚhnameÚ_ÚdomainÚkeysr   r   r   r   ]   s   
þý
r   )Nr   )r   r-   )NN)Ú__doc__r!   ÚsocketÚ	functoolsr   Úkombu.entityr   r   Ú
functionalr   Útextr   r   r   r   r'   r;   r   Ú__all__r   r   r   r   r   r   r2   r<   r   r   r   r   r   Ú<module>   s,    
	
