Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/treesum.py @ 307:64df94bf4659
treesum: Build a little static database of digest sizes.
So older Python versions can read and use treesum files produced by newer Python versions
and digest algorithms.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 07 Mar 2025 14:22:22 +0100 |
| parents | ebddfdbc3f7a |
| children | 652870b20f9e |
comparison
equal
deleted
inserted
replaced
| 306:ebddfdbc3f7a | 307:64df94bf4659 |
|---|---|
| 1508 | 1508 |
| 1509 def _hex_crc(self): | 1509 def _hex_crc(self): |
| 1510 return self._crc32.hexdigest() | 1510 return self._crc32.hexdigest() |
| 1511 | 1511 |
| 1512 def _get_digest_size(self, algo_name): | 1512 def _get_digest_size(self, algo_name): |
| 1513 """Get the `digest_size` from algorithm specifier `algo_name`. | |
| 1514 | |
| 1515 Cache this on the assumption, that algorithms do not change very | |
| 1516 often. Do this because the `digest_size` can only be given by a | |
| 1517 digest instance. | |
| 1518 | |
| 1519 """ | |
| 1513 if self._current_algo_name == algo_name: | 1520 if self._current_algo_name == algo_name: |
| 1514 return self._current_algo_digest_size | 1521 return self._current_algo_digest_size |
| 1515 h = util.algotag2algotype(algo_name)() | 1522 sz = util.algotag2digest_size(algo_name) |
| 1516 self._current_algo_name = algo_name | 1523 self._current_algo_name = algo_name |
| 1517 self._current_algo_digest_size = h.digest_size | 1524 self._current_algo_digest_size = sz |
| 1518 return self._current_algo_digest_size | 1525 return self._current_algo_digest_size |
| 1519 | 1526 |
| 1520 | 1527 |
| 1521 def print_treesum_digestfile_infos(opts): | 1528 def print_treesum_digestfile_infos(opts): |
| 1522 get_infos_from_digestfile( | 1529 get_infos_from_digestfile( |
