import hashlib import logging import sys from optparse import Values from typing import List
from pip._internal.cli.base_command import Command from pip._internal.cli.status_codes import ERROR, SUCCESS from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES from pip._internal.utils.misc import read_chunks, write_output
logger = logging.getLogger(__name__)
class HashCommand(Command): """
Compute a hash of a local package archive.
These can be used with --hash in a requirements file to do repeatable
installs. """
algorithm = options.algorithm for path in args:
write_output( "%s:\n--hash=%s:%s", path, algorithm, _hash_of_file(path, algorithm)
) return SUCCESS
def _hash_of_file(path: str, algorithm: str) -> str: """Return the hash digest of a file.""" with open(path, "rb") as archive:
hash = hashlib.new(algorithm) for chunk in read_chunks(archive):
hash.update(chunk) return hash.hexdigest()
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.