3 ig@sddlZddlZddlZddlmZddlmZddlmZddl m Z m Z ddl m Z mZddlmZmZejeZGdd d eZeeed d d ZdS) N)Values)List)Command)ERRORSUCCESS) FAVORITE_HASH STRONG_HASHES) read_chunks write_outputc@s<eZdZdZdZdZddddZeee e dd d Z dS) 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] ...TN)returnc Cs:|jjdddtdtdjdjtd|jjd|jdS) Nz-az --algorithm algorithmstorez$The hash algorithm to use: one of {}z, )destchoicesactiondefaulthelpr)cmd_opts add_optionrrformatjoinparserinsert_option_group)selfr:/tmp/pip-build-88gy_88q/pip/pip/_internal/commands/hash.py add_optionsszHashCommand.add_options)optionsargsr cCsB|s|jjtjtS|j}x |D]}td||t||q"WtS)Nz%s: --hash=%s:%s) r print_usagesysstderrrr r _hash_of_filer)rrrr pathrrrrun(s zHashCommand.run) __name__ __module__ __qualname____doc__usageZignore_require_venvrrrstrintr%rrrrr s r )r$r r c CsDt|d,}tj|}xt|D]}|j|q WWdQRX|jS)z!Return the hash digest of a file.rbN)openhashlibnewr update hexdigest)r$r archivehashchunkrrrr#5s   r#)r/loggingr!optparserZtypingrZpip._internal.cli.base_commandrZpip._internal.cli.status_codesrrZpip._internal.utils.hashesrrZpip._internal.utils.miscr r getLoggerr&loggerr r+r#rrrrs    &