comparison shasum.py @ 10:77446cd3ea6f

Move the digest generation loop from "main()" into an own function "generate_digests()". This is to prepare for proper "--check" support in the future.
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 04 Dec 2020 16:10:41 +0100
parents 81f28bf89c26
children 15c3416d3677
comparison
equal deleted inserted replaced
9:81f28bf89c26 10:77446cd3ea6f
54 sys.exit(78) # :manpage:`sysexits(3)` EX_CONFIG 54 sys.exit(78) # :manpage:`sysexits(3)` EX_CONFIG
55 55
56 if not opts.algorithm: 56 if not opts.algorithm:
57 opts.algorithm = argv2algo("1") 57 opts.algorithm = argv2algo("1")
58 58
59 if not opts.files:
60 opts.files.append('-')
61 generate_digests(opts)
62
63
64 def generate_digests(opts):
59 if opts.bsd: 65 if opts.bsd:
60 out = out_bsd 66 out = out_bsd
61 else: 67 else:
62 out = out_std 68 out = out_std
63
64 if not opts.files:
65 opts.files.append('-')
66 if len(opts.files) == 1 and opts.files[0] == '-': 69 if len(opts.files) == 1 and opts.files[0] == '-':
67 if PY2: 70 if PY2:
68 if sys.platform == "win32": 71 if sys.platform == "win32":
69 import os. msvcrt 72 import os. msvcrt
70 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) 73 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)