o
    i                     @   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   )Zcmd_optsZ
add_optionr   r   formatjoinparserZinsert_option_group)self r   ;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__usageZ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   updateZ	hexdigest)r    r   archivehashchunkr   r   r   r   4   s   

r   )r,   Zloggingr   Zoptparser   Zpip._internal.cli.base_commandr   Zpip._internal.cli.status_codesr   r   Zpip._internal.utils.hashesr   r   Zpip._internal.utils.miscr   r	   Z	getLoggerr"   loggerr
   r(   r   r   r   r   r   <module>   s    
&