o
    wvXj²  ã                   @   s4   d Z ddlmZmZ ddlmZ G dd„ deƒZdS )zEThe ``celery list bindings`` command, used to inspect queue bindings.é    )Úabsolute_importÚunicode_literals)ÚCommandc                   @   s&   e Zd ZdZdZdd„ Zddd„ZdS )	Úlist_z®Get info from broker.

    Note:
       For RabbitMQ the management plugin is required.

    Example:
        .. code-block:: console

            $ celery list bindings
    z
[bindings]c                    sp   z|  ¡ }W n ty   ˆ  d¡‚w ‡ fdd„}|dddƒ |dddƒ |D ]}||d |d	 |d
 ƒ q'd S )Nz$Your transport cannot list bindings.c                    s   ˆ   d | ||¡¡S )Nz{0:<28} {1:<28} {2})ÚoutÚformat)ÚqÚeÚr©Úself© úL/var/www/html/myproject/venv/lib/python3.10/site-packages/celery/bin/list.pyÚfmt   s   z list_.list_bindings.<locals>.fmtÚQueueÚExchangezRouting Keyz----------------ÚdestinationÚsourceÚrouting_key)Úget_bindingsÚNotImplementedErrorÚError)r   Ú
managementÚbindingsr   Úbr   r   r   Úlist_bindings   s   
ÿÿzlist_.list_bindingsNc                 O   s’   d| j i}d |¡}|s|  d |¡¡‚||vr!|  d ||¡¡‚| j ¡ �}| jj |¡ ¡  || |j	ƒ W d   ƒ d S 1 sBw   Y  d S )Nr   z, z%Missing argument, specify one of: {0}z(unknown topic {0!r} (choose one of: {1}))
r   ÚjoinÚ
UsageErrorr   ÚappÚ
connectionÚamqpÚTaskConsumerÚdeclareÚmanager)r   ÚwhatÚ_ÚkwÚtopicsÚ	availableÚconnr   r   r   Úrun"   s    

ÿÿÿ"þz	list_.run)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úargsr   r*   r   r   r   r   r      s
    r   N)r.   Ú
__future__r   r   Úcelery.bin.baser   r   r   r   r   r   Ú<module>   s    