o
    wvXj
  ã                   @   sL   d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 G dd„ deƒZ
dS )	zBThe ``celery purge`` program, used to delete messages from queues.é    )Úabsolute_importÚunicode_literals)ÚCommand)Úkeys)Útextc                   @   s:   e Zd ZdZdZdZdZdZdd„ Zdd
d„Z	dd„ Z
d	S )ÚpurgezuErase all messages from all known task queues.

    Warning:
        There's no undo operation for this command.
    z•{warning}: This will remove all tasks from {queues}: {names}.
         There is no undo for this operation!

(to skip this prompt use the -f option)
z)Are you sure you want to delete all tasksz9Purged {mnum} {messages} from {qnum} known task {queues}.z'No messages purged from {qnum} {queues}c                 C   sF   |  d¡}|jdddddd� |jdd	g d
d� |jddg dd� d S )NzPurging Optionsz--forcez-fÚ
store_trueFzDon't prompt for verification)ÚactionÚdefaultÚhelpz--queuesz-Qz-Comma separated list of queue names to purge.)r
   r   z--exclude-queuesz-Xz2Comma separated list of queues names not to purge.)Úadd_argument_groupÚadd_argument)ÚselfÚparserÚgroup© r   úM/var/www/html/myproject/venv/lib/python3.10/site-packages/celery/bin/purge.pyÚadd_arguments   s   
þþ
þzpurge.add_argumentsFNc           
   
      s  t t |pg ¡ƒ}t t |pg ¡ƒ}|pt tˆjjjƒƒ| }t|ƒ}d }|ro|sNˆ ˆj	j
ˆj d¡t |d¡d t|ƒ¡d�¡ ˆ ˆjdd¡dkrNd S ˆj ¡ �‰ t‡ ‡fdd	„|D ƒƒ}W d   ƒ n1 sjw   Y  |rtˆjnˆj}	ˆ |	j
||t |d
¡t |d¡d�¡ d S )NÚWARNINGÚqueuez, )ÚwarningÚqueuesÚnames)ÚyesÚnor   r   c                 3   s   � | ]	}ˆ  ˆ |¡V  qd S )N)Ú_purge)Ú.0r   ©Úconnr   r   r   Ú	<genexpr>:   s   € zpurge.run.<locals>.<genexpr>Úmessage)ÚmnumÚqnumÚmessagesr   )Úsetr   Ústr_to_listr   ÚappÚamqpr   ÚlenÚoutÚwarn_preludeÚformatÚcoloredÚredÚ	pluralizeÚjoinÚsortedÚaskÚwarn_promptÚconnection_for_writeÚsumÚ
fmt_purgedÚ	fmt_empty)
r   Úforcer   Úexclude_queuesÚkwargsÚexcluder   r"   r#   Úfmtr   r   r   Úrun)   s.   


ýÿ

ýz	purge.runc                 C   s*   z	|j  |¡pdW S  |jy   Y dS w )Nr   )Údefault_channelÚqueue_purgeÚchannel_errors)r   r   r   r   r   r   r   A   s
   ÿzpurge._purge)FNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r*   r2   r5   r6   r   r<   r   r   r   r   r   r   	   s    ÿ
r   N)rC   Ú
__future__r   r   Úcelery.bin.baser   Úcelery.fiver   Úcelery.utilsr   r   r   r   r   r   Ú<module>   s    