U ÀÒ.eÇã@s‚ddlmZddlZddlZddlZddlmZddlmZddl m Z m Z ddl m Z mZe e¡ZGdd„deƒZd d „ZdS) é)Úabsolute_importN)ÚCommand)ÚERROR)Ú FAVORITE_HASHÚ STRONG_HASHES)Ú read_chunksÚ write_outputcs0eZdZdZdZdZ‡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 sJtt|ƒj||Ž|jjdddtdtdd t¡d�|j  d|j¡dS) Nz-az --algorithmÚ algorithmZstorez$The hash algorithm to use: one of %sz, )ÚdestÚchoicesÚactionÚdefaultÚhelpr) Úsuperr Ú__init__Zcmd_optsZ add_optionrrÚjoinÚparserZinsert_option_group)ÚselfÚargsÚkw©Ú __class__©ú?/usr/lib/python3.8/site-packages/pip/_internal/commands/hash.pyrsÿúzHashCommand.__init__cCs>|s|j tj¡tS|j}|D]}td||t||ƒƒq dS)Nz%s: --hash=%s:%s)rZ print_usageÚsysÚstderrrr rÚ _hash_of_file)rZoptionsrr ÚpathrrrÚrun)sÿzHashCommand.run) Ú__name__Ú __module__Ú __qualname__Ú__doc__ZusageZignore_require_venvrrÚ __classcell__rrrrr s  r c Cs@t|dƒ�(}t |¡}t|ƒD]}| |¡qW5QRX| ¡S)z!Return the hash digest of a file.Úrb)ÚopenÚhashlibÚnewrÚupdateZ hexdigest)rr ÚarchiveÚhashÚchunkrrrr4s    r)Z __future__rr'ZloggingrZpip._internal.cli.base_commandrZpip._internal.cli.status_codesrZpip._internal.utils.hashesrrZpip._internal.utils.miscrrZ getLoggerr Zloggerr rrrrrÚs    "