3 Pf=@s~ddlmZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ejeZGdddeZd d ZdS) )absolute_importN)Command)ERROR) read_chunks) FAVORITE_HASH STRONG_HASHEScs4eZdZdZdZdZdZfddZddZZ 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] ...z#Compute hashes of package archives.c sJtt|j|||jjdddtdtddjtd|jj d|jdS) Nz-az --algorithm algorithmZstorez$The hash algorithm to use: one of %sz, )destchoicesactiondefaulthelpr) superr__init__Zcmd_optsZ add_optionrrjoinparserZinsert_option_group)selfargskw) __class__/usr/lib/python3.6/hash.pyrszHashCommand.__init__cCsD|s|jjtjtS|j}x"|D]}tjd||t||q"WdS)Nz%s: --hash=%s:%s) rZ print_usagesysstderrrr loggerinfo _hash_of_file)rZoptionsrr pathrrrrun(s zHashCommand.run) __name__ __module__ __qualname____doc__nameZusageZsummaryrr __classcell__rr)rrrs  rc CsDt|d,}tj|}xt|D]}|j|q WWdQRX|jS)z!Return the hash digest of a file.rbN)openhashlibnewrupdateZ hexdigest)rr archiver chunkrrrr3s   r)Z __future__rr)ZloggingrZpip.basecommandrZpip.status_codesrZ pip.utilsrZpip.utils.hashesrrZ getLoggerr!rrrrrrrs     #