hashsums
DEF_HASH_ALG
module-attribute
¶
DEF_HASH_ALG = 'sha256'
Algorithm to use and string to prepend to a resulting hashsum.
DirHashsums
module-attribute
¶
DirHashsums = Dict[str, Any]
Nested dict representing a directory.
str values represent files (checksum) or symlinks (target path), dict values represent sub-directories.
hashsum ¶
hashsum(data: Union[bytes, BinaryIO], alg: str)
Compute hashsum from given binary file stream using selected algorithm.
Source code in src/metador_core/util/hashsums.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
qualified_hashsum ¶
qualified_hashsum(
data: Union[bytes, BinaryIO], alg: str = DEF_HASH_ALG
)
Like hashsum, but prepends the algorithm to the string.
Source code in src/metador_core/util/hashsums.py
40 41 42 |
|
rel_symlink ¶
rel_symlink(base: Path, dir: Path) -> Optional[Path]
From base path and a symlink path, normalize it to be relative to base.
Mainly used to eliminate .. in paths.
If path points outside base, returns None.
Source code in src/metador_core/util/hashsums.py
58 59 60 61 62 63 64 65 66 67 68 69 |
|
dir_hashsums ¶
dir_hashsums(
dir: Path, alg: str = DEF_HASH_ALG
) -> DirHashsums
Return hashsums of all files.
Resulting paths are relative to the provided dir
.
In-directory symlinks are treated like files and the target is stored instead of computing a checksum.
Out-of-directory symlinks are not allowed.
Source code in src/metador_core/util/hashsums.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|