Mercurial > hgrepos > Python > apps > py-cutils
changeset 4:67d10529ce88
FIX: "-" filename handling now consistent with Perl shasum
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 04 Dec 2020 12:37:29 +0100 |
| parents | 5a6ed622846c |
| children | bbcb225640de |
| files | shasum.py |
| diffstat | 1 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/shasum.py Fri Dec 04 12:05:55 2020 +0100 +++ b/shasum.py Fri Dec 04 12:37:29 2020 +0100 @@ -42,17 +42,17 @@ sys.exit(78) # :manpage:`sysexits(3)` EX_CONFIG if not opts.files: opts.files.append("-") - for fn in opts.files: - if fn == "-": - if PY2: - if sys.platform == "win32": - import os. msvcrt - msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) - source = sys.stdin - else: - source = sys.stdin.buffer - print(compute_digest(hashlib.sha256, source)) + if len(opts.files) == 1 and opts.files[0] == "-": + if PY2: + if sys.platform == "win32": + import os. msvcrt + msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) + source = sys.stdin else: + source = sys.stdin.buffer + print(compute_digest(hashlib.sha256, source)) + else: + for fn in opts.files: with open(fn, "rb") as source: print(compute_digest(hashlib.sha256, source))
