#!/usr/bin/env python
import sys
import anydbm
import dohdbm as dbmod
def prefix(string, max_len):
if string[max_len:]:
return string[:max_len] + '...'
else:
return string
def display(key, value):
sys.stdout.write('-> %-20s %s\n' % (prefix(key, 20), prefix(value, 1000)))
def main():
for filename in sys.argv[1:]:
try:
db = dbmod.open(filename, 'r')
except dbmod.error:
sys.stderr.write('Error opening %s - continuing\n' % filename)
continue
for key in db.keys():
value = db[key]
display(key, value)
db.close()
main()