509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ÝPf=  ã               @   s~   d dl mZ 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
 d dlmZmZ ejeƒZG dd„ deƒZd	d
„ ZdS )é    )Úabsolute_importN)ÚCommand)ÚERROR)Úread_chunks)ÚFAVORITE_HASHÚSTRONG_HASHESc                   s4   e Zd ZdZdZdZdZ‡ fdd„Zdd„ Z‡  Z	S )	ÚHashCommandzŽ
    Compute a hash of a local package archive.

    These can be used with --hash in a requirements file to do repeatable
    installs.

    Úhashz%prog [options] <file> ...z#Compute hashes of package archives.c          
      sJ   t t| ƒj||Ž | jjdddtdtddjtƒ d� | jj	d| jƒ d S )	Nz-az--algorithmÚ	algorithmZstorez$The hash algorithm to use: one of %sz, )ÚdestÚchoicesÚactionÚdefaultÚhelpr   )
Úsuperr   Ú__init__Zcmd_optsZ
add_optionr   r   ÚjoinÚparserZinsert_option_group)ÚselfÚargsÚkw)Ú	__class__© ú/usr/lib/python3.6/hash.pyr      s    zHashCommand.__init__c             C   sD   |s| j jtjƒ tS |j}x"|D ]}tjd||t||ƒƒ q"W d S )Nz%s:
--hash=%s:%s)	r   Zprint_usageÚsysÚstderrr   r
   ÚloggerÚinfoÚ_hash_of_file)r   Zoptionsr   r
   Úpathr   r   r   Úrun(   s    
zHashCommand.run)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameZusageZsummaryr   r    Ú__classcell__r   r   )r   r   r      s   r   c          
   C   sD   t | dƒ�,}tj|ƒ}xt|ƒD ]}|j|ƒ q W W dQ R X |jƒ S )z!Return the hash digest of a file.ÚrbN)ÚopenÚhashlibÚnewr   ÚupdateZ	hexdigest)r   r
   Úarchiver	   Úchunkr   r   r   r   3   s
    
r   )Z
__future__r   r)   Zloggingr   Zpip.basecommandr   Zpip.status_codesr   Z	pip.utilsr   Zpip.utils.hashesr   r   Z	getLoggerr!   r   r   r   r   r   r   r   Ú<module>   s   
#