Hash files using given hashfunc. Parameters ---------- idirs : directory path Directory containing files to be hashed. hashfunc : hash function Function to be used to hash the files.
(idirs, hashfunc)
| 119 | #------------- |
| 120 | |
| 121 | def _compute_hash(idirs, hashfunc): |
| 122 | """Hash files using given hashfunc. |
| 123 | |
| 124 | Parameters |
| 125 | ---------- |
| 126 | idirs : directory path |
| 127 | Directory containing files to be hashed. |
| 128 | hashfunc : hash function |
| 129 | Function to be used to hash the files. |
| 130 | |
| 131 | """ |
| 132 | released = paver.path.path(idirs).listdir() |
| 133 | checksums = [] |
| 134 | for fpath in sorted(released): |
| 135 | with open(fpath, 'rb') as fin: |
| 136 | fhash = hashfunc(fin.read()) |
| 137 | checksums.append( |
| 138 | '%s %s' % (fhash.hexdigest(), os.path.basename(fpath))) |
| 139 | return checksums |
| 140 | |
| 141 | |
| 142 | def compute_md5(idirs): |
no test coverage detected