Skip to content

Commit a547468

Browse files
committed
simplify reorganize detection
1 parent 7059a0c commit a547468

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Lib/dbm/__main__.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,17 @@ def _dump_command(filename):
3535
def _reorganize_command(filename):
3636
try:
3737
with dbm_open(filename, "c") as db:
38-
if whichdb(filename) in ["dbm.sqlite3", "dbm.gnu", "dbm.dumb"]:
38+
if db.hasattr("reorganize"):
3939
db.reorganize()
40-
print(f"Reorganized database '{filename}'")
40+
print(f"Reorganized database: '{filename}'", file=sys.stderr)
4141
else:
42-
print(
43-
f"Database type doesn't support reorganize method",
44-
file=sys.stderr,
45-
)
42+
print("Database type doesn't support reorganize method",
43+
file=sys.stderr)
4644
return 1
4745
return 0
4846
except error:
49-
print(
50-
f"Error: Database '{filename}' not found or cannot be opened",
51-
file=sys.stderr,
52-
)
47+
print(f"Error: Database '{filename}' not found or cannot be opened",
48+
file=sys.stderr)
5349
return 1
5450

5551

0 commit comments

Comments
 (0)