Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/treesum.py @ 176:7f5d05a625fd
Implement preconditions for some debug logging
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 11 Jan 2025 13:20:14 +0100 |
| parents | fc1055878775 |
| children | 089c40240061 |
comparison
equal
deleted
inserted
replaced
| 175:506d895a8500 | 176:7f5d05a625fd |
|---|---|
| 15 | 15 |
| 16 import argparse | 16 import argparse |
| 17 import base64 | 17 import base64 |
| 18 import binascii | 18 import binascii |
| 19 import datetime | 19 import datetime |
| 20 import logging | |
| 20 import os | 21 import os |
| 21 import stat | 22 import stat |
| 22 import sys | 23 import sys |
| 23 import time | 24 import time |
| 24 | 25 |
| 57 "(OpenBSD).") | 58 "(OpenBSD).") |
| 58 gp.add_argument( | 59 gp.add_argument( |
| 59 "--comment", action="append", default=[], | 60 "--comment", action="append", default=[], |
| 60 help="Put given comment COMMENT into the output as \"COMMENT\". " | 61 help="Put given comment COMMENT into the output as \"COMMENT\". " |
| 61 "Can be given more than once.") | 62 "Can be given more than once.") |
| 63 gp.add_argument( | |
| 64 "--debug", action="store_true", | |
| 65 help="Activate debug logging to stderr") | |
| 62 gp.add_argument( | 66 gp.add_argument( |
| 63 "--follow-directory-symlinks", "-l", action="store_true", | 67 "--follow-directory-symlinks", "-l", action="store_true", |
| 64 dest="follow_directory_symlinks", | 68 dest="follow_directory_symlinks", |
| 65 help="Follow symbolic links to directories when walking a " | 69 help="Follow symbolic links to directories when walking a " |
| 66 "directory tree. Note that this is different from using " | 70 "directory tree. Note that this is different from using " |
| 200 parser.print_help() | 204 parser.print_help() |
| 201 return 0 | 205 return 0 |
| 202 | 206 |
| 203 # Reparse strictly | 207 # Reparse strictly |
| 204 opts = parser.parse_args(args=argv) | 208 opts = parser.parse_args(args=argv) |
| 209 | |
| 210 # Minimal logging -- just for debugging - not for more "normal" use | |
| 211 logging.basicConfig( | |
| 212 level=logging.DEBUG if opts.debug else logging.WARNING, | |
| 213 stream=sys.stderr, | |
| 214 format="[%(asctime)s][%(levelname)s][%(process)d:%(name)s] %(message)s" | |
| 215 ) | |
| 216 logging.captureWarnings(True) | |
| 205 | 217 |
| 206 return treesum(opts) | 218 return treesum(opts) |
| 207 | 219 |
| 208 | 220 |
| 209 def gen_generate_opts(directories=[], | 221 def gen_generate_opts(directories=[], |
