o
    ©„j�  ã                   @   s”   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZ d dlmZmZ e e¡ZG dd„ deƒZd	ed
edefdd„ZdS )é    N)ÚValues)ÚCommand)ÚERRORÚSUCCESS)ÚFAVORITE_HASHÚSTRONG_HASHES)Úread_chunksÚwrite_outputc                   @   s<   e Zd ZdZdZdZddd„Zded	ee	 de
fd
d„ZdS )ÚHashCommandz�
    Compute a hash of a local package archive.

    These can be used with --hash in a requirements file to do repeatable
    installs.
    z%prog [options] <file> ...TÚreturnNc                 C   s:   | j jdddtdtd d t¡¡d� | j d| j ¡ d S )	Nz-az--algorithmÚ	algorithmÚstorez$The hash algorithm to use: one of {}z, )ÚdestÚchoicesÚactionÚdefaultÚhelpr   )Úcmd_optsÚ
add_optionr   r   ÚformatÚjoinÚparserÚinsert_option_group)Úself© r   úY/var/www/html/django_cbt/venv/lib/python3.10/site-packages/pip/_internal/commands/hash.pyÚadd_options   s   ÿùzHashCommand.add_optionsÚoptionsÚargsc                 C   s>   |s| j  tj¡ tS |j}|D ]}td||t||ƒƒ qtS )Nz%s:
--hash=%s:%s)	r   Úprint_usageÚsysÚstderrr   r   r	   Ú_hash_of_filer   )r   r   r   r   Úpathr   r   r   Úrun'   s   ÿzHashCommand.run)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚusageÚignore_require_venvr   r   ÚlistÚstrÚintr$   r   r   r   r   r
      s    
r
   r#   r   r   c                 C   sZ   t | dƒ�}t |¡}t|ƒD ]}| |¡ qW d  ƒ | ¡ S 1 s$w   Y  | ¡ S )z!Return the hash digest of a file.ÚrbN)ÚopenÚhashlibÚnewr   ÚupdateÚ	hexdigest)r#   r   ÚarchiveÚhashÚchunkr   r   r   r"   4   s   
ÿ
þür"   )r0   Úloggingr    Úoptparser   Úpip._internal.cli.base_commandr   Úpip._internal.cli.status_codesr   r   Úpip._internal.utils.hashesr   r   Úpip._internal.utils.miscr   r	   Ú	getLoggerr%   Úloggerr
   r,   r"   r   r   r   r   Ú<module>   s    
&