Python pip._internal.utils.misc.read_chunks() Examples

The following are 30 code examples of pip._internal.utils.misc.read_chunks(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pip._internal.utils.misc , or try the search function .
Example #1
Source File: hash.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #2
Source File: hashes.py    From stopstalk-deployment with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #3
Source File: hash.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #4
Source File: hashes.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #5
Source File: hash.py    From Weapon-Detection-And-Classification with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #6
Source File: hashes.py    From Weapon-Detection-And-Classification with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #7
Source File: hash.py    From rules_pip with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #8
Source File: hashes.py    From rules_pip with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #9
Source File: hash.py    From guildai with Apache License 2.0 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #10
Source File: hashes.py    From guildai with Apache License 2.0 5 votes vote down vote up
def check_against_file(self, file):
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #11
Source File: hash.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #12
Source File: hashes.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #13
Source File: hash.py    From CogAlg with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #14
Source File: wheel.py    From CogAlg with MIT License 5 votes vote down vote up
def hash_file(path, blocksize=1 << 20):
    # type: (str, int) -> Tuple[Any, int]
    """Return (hash, length) for path using hashlib.sha256()"""
    h = hashlib.sha256()
    length = 0
    with open(path, 'rb') as f:
        for block in read_chunks(f, size=blocksize):
            length += len(block)
            h.update(block)
    return (h, length)  # type: ignore 
Example #15
Source File: hashes.py    From CogAlg with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #16
Source File: hash.py    From stopstalk-deployment with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #17
Source File: hashes.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #18
Source File: hash.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #19
Source File: hashes.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #20
Source File: hash.py    From android_universal with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #21
Source File: hashes.py    From android_universal with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #22
Source File: hash.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #23
Source File: hashes.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #24
Source File: hash.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #25
Source File: hashes.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #26
Source File: hash.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #27
Source File: hash.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #28
Source File: hashes.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def check_against_file(self, file):
        # type: (BinaryIO) -> None
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file)) 
Example #29
Source File: hash.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def _hash_of_file(path, algorithm):
    """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() 
Example #30
Source File: hashes.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def check_against_file(self, file):
        """Check good hashes against a file-like object

        Raise HashMismatch if none match.

        """
        return self.check_against_chunks(read_chunks(file))