Mercurial > hgrepos > Python > apps > py-cutils
diff cutils/treesum.py @ 172:804a823c63f5
Now the selection of the default algorithm depends on availiability in hashlib
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 10 Jan 2025 11:38:31 +0100 |
| parents | 8945be6b404e |
| children | e081b6ee5570 |
line wrap: on
line diff
--- a/cutils/treesum.py Fri Jan 10 11:25:56 2025 +0100 +++ b/cutils/treesum.py Fri Jan 10 11:38:31 2025 +0100 @@ -40,12 +40,14 @@ """ gp.add_argument( "--algorithm", "-a", action="store", type=util.argv2algo, - help="1 (aka sha1), 224, 256, 384, 512, " + help="1 (aka sha1), 224, 256 (aka sha256), 384, 512 (aka sha512), " "3 (alias for sha3-512), 3-224, 3-256, 3-384, 3-512, " - "blake2b, blake2b-256 (default), blake2s, " + "blake2b, blake2b-256, blake2s, " "blake2 (alias for blake2b), " "blake2-256 (alias for blake2b-256), " - "md5") + "md5. " + "The default depends on availability in hashlib: " + "blake2b-256, sha256 or sha1.") gp.add_argument( "--append-output", action="store_true", dest="append_output", help="Append to the output file instead of overwriting it.") @@ -205,7 +207,7 @@ def gen_generate_opts(directories=[], - algorithm="BLAKE2b-256", + algorithm=util.default_algotag(), append_output=False, base64=False, comment=[], @@ -221,8 +223,7 @@ size_only=False): opts = argparse.Namespace( directories=directories, - algorithm=(util.algotag2algotype(algorithm), - algorithm), + algorithm=util.argv2algo(algorithm), append_output=append_output, base64=base64, comment=comment, @@ -251,7 +252,7 @@ def generate_treesum(opts): # Provide defaults if not opts.algorithm: - opts.algorithm = util.argv2algo("blake2b-256") + opts.algorithm = util.argv2algo(util.default_algotag()) if not opts.directories: opts.directories.append(".")
