3

Q'íc=ã@s~ddlmZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
ejeƒZGdd„deƒZd	d
„ZdS)é)Úabsolute_importN)ÚCommand)ÚERROR)Úread_chunks)Ú
FAVORITE_HASHÚ
STRONG_HASHEScs4eZdZdZdZdZdZ‡fdd„Zdd„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
sJtt|ƒj||Ž|jjdddtdtddjtƒd|jj	d|jƒdS)	Nz-az--algorithmÚ	algorithmÚstorez$The hash algorithm to use: one of %sz, )ÚdestÚchoicesÚactionÚdefaultÚhelpr)
ÚsuperrÚ__init__Úcmd_optsÚ
add_optionrrÚjoinÚparserÚinsert_option_group)ÚselfÚargsÚkw)Ú	__class__©ú0/tmp/pip-build-l_bcah40/pip/pip/commands/hash.pyrszHashCommand.__init__cCsD|s|jjtjƒtS|j}x"|D]}tjd||t||ƒƒq"WdS)Nz%s:
--hash=%s:%s)	rÚprint_usageÚsysÚstderrrr
ÚloggerÚinfoÚ
_hash_of_file)rÚoptionsrr
ÚpathrrrÚrun(s
zHashCommand.run)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚusageÚsummaryrr&Ú
__classcell__rr)rrrsrc
CsDt|dƒ,}tj|ƒ}xt|ƒD]}|j|ƒq WWdQRX|jƒS)z!Return the hash digest of a file.ÚrbN)ÚopenÚhashlibÚnewrÚupdateÚ	hexdigest)r%r
Úarchiver	Úchunkrrrr#3s

r#)Ú
__future__rr1ÚloggingrÚpip.basecommandrÚpip.status_codesrÚ	pip.utilsrÚpip.utils.hashesrrÚ	getLoggerr'r!rr#rrrrÚ<module>s
#