U
.e @ s d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl m
Z
mZ d dlm
Z
mZ eeZG dd deZd d
ZdS ) )absolute_importN)Command)ERROR)
FAVORITE_HASH
STRONG_HASHES)read_chunkswrite_outputc s0 e Zd ZdZdZdZ fddZdd 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|| | jjdddtdtddt d | j d| j d S ) Nz-az--algorithm algorithmZstorez$The hash algorithm to use: one of %sz, )destchoicesactiondefaulthelpr )
superr __init__Zcmd_optsZ
add_optionr r joinparserZinsert_option_group)selfargskw __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_usagesysstderrr 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)openhashlibnewr updateZ hexdigest)r r
archivehashchunkr 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
"