U
ÀÒ.eÇ ã @ s‚ d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl m
Z
mZ d dlm
Z
mZ e e¡ZG dd„ deƒZd d
„ ZdS )é )Úabsolute_importN)ÚCommand)ÚERROR)Ú
FAVORITE_HASHÚ
STRONG_HASHES)Úread_chunksÚwrite_outputc s0 e Zd ZdZdZdZ‡ fdd„Zdd„ Z‡ ZS )Ú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] ...Tc sJ t t| ƒj||Ž | jjdddtdtdd t¡ d� | j d| j¡ d S ) Nz-az--algorithmÚ algorithmZstorez$The hash algorithm to use: one of %sz, )ÚdestÚchoicesÚactionÚdefaultÚhelpr )
Úsuperr Ú__init__Zcmd_optsZ
add_optionr r ÚjoinÚparserZinsert_option_group)ÚselfÚargsÚkw©Ú __class__© ú?/usr/lib/python3.8/site-packages/pip/_internal/commands/hash.pyr s ÿúzHashCommand.__init__c C s> |s| j tj¡ tS |j}|D ]}td||t||ƒƒ q d S )Nz%s:
--hash=%s:%s)r Zprint_usageÚsysÚstderrr r
r Ú
_hash_of_file)r Zoptionsr r
Úpathr r r Úrun) s ÿzHashCommand.run) Ú__name__Ú
__module__Ú__qualname__Ú__doc__ZusageZignore_require_venvr r Ú
__classcell__r r r r r s
r c C s@ t | dƒ�(}t |¡}t|ƒD ]}| |¡ qW 5 Q R X | ¡ S )z!Return the hash digest of a file.Úrb)ÚopenÚhashlibÚnewr ÚupdateZ hexdigest)r r
ÚarchiveÚhashÚchunkr r r r 4 s
r )Z
__future__r r' Zloggingr Zpip._internal.cli.base_commandr Zpip._internal.cli.status_codesr Zpip._internal.utils.hashesr r Zpip._internal.utils.miscr r Z getLoggerr Zloggerr r r r r r Ú s
"