Mercurial > p > roundup > code
comparison scripts/dump_dbm_sessions_db.py @ 7780:9ba04f37896f
chore: lint cleanups
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 04 Mar 2024 21:18:51 -0500 |
| parents | 1188bb423f92 |
| children |
comparison
equal
deleted
inserted
replaced
| 7779:4919435ac231 | 7780:9ba04f37896f |
|---|---|
| 23 data | 23 data |
| 24 | 24 |
| 25 if pretty printed. | 25 if pretty printed. |
| 26 """ | 26 """ |
| 27 | 27 |
| 28 import argparse, dbm, json, marshal, os, sys | 28 import argparse |
| 29 import dbm | |
| 30 import json | |
| 31 import marshal | |
| 32 import os | |
| 33 import sys | |
| 29 from datetime import datetime | 34 from datetime import datetime |
| 35 | |
| 30 | 36 |
| 31 def indent(text, amount, ch=" "): | 37 def indent(text, amount, ch=" "): |
| 32 """ Found at: https://stackoverflow.com/a/8348914 | 38 """ Found at: https://stackoverflow.com/a/8348914 |
| 33 """ | 39 """ |
| 34 padding = amount * ch | 40 padding = amount * ch |
| 78 os.stat(file) | 84 os.stat(file) |
| 79 print(" perhaps file is invalid or was created with a different version of Python?") | 85 print(" perhaps file is invalid or was created with a different version of Python?") |
| 80 except OSError: | 86 except OSError: |
| 81 # the file does exist on disk. | 87 # the file does exist on disk. |
| 82 pass | 88 pass |
| 83 exit(1) | 89 sys.exit(1) |
| 84 | 90 |
| 85 if args.keysonly: | 91 if args.keysonly: |
| 86 for k in sorted(db.keys()): | 92 for k in sorted(db.keys()): |
| 87 print("%s"%k) | 93 print("%s"%k) |
| 88 exit(0) | 94 sys.exit(0) |
| 89 | 95 |
| 90 if args.key: | 96 if args.key: |
| 91 for k in args.key: | 97 for k in args.key: |
| 92 try: | 98 try: |
| 93 print_marshal(k) | 99 print_marshal(k) |
| 94 except (ValueError): | 100 except (ValueError): |
| 95 print_raw(k) | 101 print_raw(k) |
| 96 exit(0) | 102 sys.exit(0) |
| 97 | 103 |
| 98 k = db.firstkey() | 104 k = db.firstkey() |
| 99 while k is not None: | 105 while k is not None: |
| 100 try: | 106 try: |
| 101 print_marshal(k) | 107 print_marshal(k) |
