o
    ›¨ÊhÙ  ã                   @   s,   d dl mZ d dlmZ G dd„ deƒZdS )é    )ÚBaseCommand)Úconnectionsc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚCommandú'Clears out the search index completely.c                 C   s@   |j dddddd� |j ddd	g d
d� |j dddddd� d S )Nz	--noinputÚstore_falseÚinteractiveTzRIf provided, no prompts will be issued to the user and the data will be wiped out.)ÚactionÚdestÚdefaultÚhelpz-uz--usingÚappendzdUpdate only the named backend (can be used multiple times). By default all backends will be updated.)r   r
   r   z
--nocommitÚcommitz&Will pass commit=False to the backend.)Úadd_argument)ÚselfÚparser© r   úZ/var/www/html/env/lib/python3.10/site-packages/haystack/management/commands/clear_index.pyÚadd_arguments	   s*   ûû
ûzCommand.add_argumentsc                 K   sä   t | dd¡ƒ| _| dd¡| _| d¡}|stj ¡ }| dd¡rF| j dd 	|¡ ¡ | j d	¡ t
d
ƒ}| ¡  d¡sF| j d¡ dS | jdkrQ| j d¡ |D ]}t|  ¡ }|j| jd� qS| jdkrp| j d¡ dS dS )r   Ú	verbosityé   r   TÚusingr   z[WARNING: This will irreparably remove EVERYTHING from your search index in connection '%s'.z', 'z_Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.z)Are you sure you wish to continue? [y/N] ÚyzNo action taken.Nz;Removing all documents from your index because you said so.)r   zAll documents removed.)ÚintÚgetr   r   r   Úconnections_infoÚkeysÚstdoutÚwriteÚjoinÚinputÚlowerÚ
startswithÚget_backendÚclear)r   Úoptionsr   Ú	yes_or_noÚbackend_nameÚbackendr   r   r   Úhandle!   s8   

ÿÿÿ
ÿ
ÿzCommand.handleN)Ú__name__Ú
__module__Ú__qualname__r   r   r(   r   r   r   r   r      s    r   N)Údjango.core.management.baser   Úhaystackr   r   r   r   r   r   Ú<module>   s    