Source code for pathlib_mate.mate_hashes_methods

# -*- coding: utf-8 -*-

"""
Provide file hash functions.
"""

from typing import TYPE_CHECKING

from .hashes import md5file, sha256file, sha512file

if TYPE_CHECKING:  # pragma: no cover
    from .pathlib2 import Path


[docs]class HashesMethods(object): """ Provide hash functions. """ # --- file check sum ---
[docs] def get_partial_md5(self, nbytes): """ Return md5 check sum of first n bytes of this file. :type self: Path :type nbytes: int :rtype: str """ return md5file(abspath=self.abspath, nbytes=nbytes)
@property def md5(self): """ Return md5 check sum of this file. :type self: Path :rtype: str """ return md5file(self.abspath)
[docs] def get_partial_sha256(self, nbytes): """ Return sha256 check sum of first n bytes of this file. :type self: Path :type nbytes: int :rtype: str """ return sha256file(abspath=self.abspath, nbytes=nbytes)
@property def sha256(self): """ Return sha256 check sum of this file. :type self: Path :rtype: str """ return sha256file(self.abspath)
[docs] def get_partial_sha512(self, nbytes): """ Return sha512 check sum of first n bytes of this file. :type self: Path :type nbytes: int :rtype: str """ return sha512file(abspath=self.abspath, nbytes=nbytes)
@property def sha512(self): """ Return md5 check sum of this file. :type self: Path :rtype: str """ return sha512file(self.abspath)