Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/treesum.py @ 149:f717854be1de
Put the defaults generation when generating directory digests into "generate_treesum()" instead of "main()"
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 03 Jan 2025 17:16:05 +0100 |
| parents | 17d6e760143f |
| children | f84cf853da22 |
comparison
equal
deleted
inserted
replaced
| 148:17d6e760143f | 149:f717854be1de |
|---|---|
| 165 parser.print_help() | 165 parser.print_help() |
| 166 sys.exit(0) | 166 sys.exit(0) |
| 167 | 167 |
| 168 # Reparse strictly | 168 # Reparse strictly |
| 169 opts = parser.parse_args(args=argv) | 169 opts = parser.parse_args(args=argv) |
| 170 | |
| 171 if not opts.algorithm: | |
| 172 opts.algorithm = util.argv2algo("blake2b-256") | |
| 173 | 170 |
| 174 return treesum(opts) | 171 return treesum(opts) |
| 175 | 172 |
| 176 | 173 |
| 177 def gen_generate_opts(directories=[], | 174 def gen_generate_opts(directories=[], |
| 205 raise RuntimeError( | 202 raise RuntimeError( |
| 206 "command `{}' not yet handled".format(opts.subcommand)) | 203 "command `{}' not yet handled".format(opts.subcommand)) |
| 207 | 204 |
| 208 | 205 |
| 209 def generate_treesum(opts): | 206 def generate_treesum(opts): |
| 207 # Provide defaults | |
| 208 if not opts.algorithm: | |
| 209 opts.algorithm = util.argv2algo("blake2b-256") | |
| 210 if not opts.directories: | 210 if not opts.directories: |
| 211 opts.directories.append(".") | 211 opts.directories.append(".") |
| 212 | 212 |
| 213 if opts.output is None or opts.output == "-": | 213 if opts.output is None or opts.output == "-": |
| 214 if hasattr(sys.stdout, "buffer"): | 214 if hasattr(sys.stdout, "buffer"): |
