#!/usr/bin/env python2

import anydbm
import marshal
import sys
import os.path


def usage():
  cmd = sys.argv[0]
  sys.stderr.write("Usage: %s DBFILE [...]\n\n" % os.path.basename(cmd))
  sys.stderr.write("Dump .db database files created by cvs2svn.\n")
  sys.exit(1)

  
def main():
  argc = len(sys.argv)
  if argc < 2:
    usage()
  for db_file in sys.argv[1:]:
    print '*** ' + db_file + ' ***'
    print ''
    db_file = anydbm.open(sys.argv[1], 'r')
    keys = db_file.keys()
    keys.sort()
    longest_len = 0
    for key in keys:
      this_len = len(key)
      if this_len > longest_len:
        longest_len = this_len
    for key in keys:
      this_len = len(key)
      value = str(marshal.loads(db_file[key]))
      print ' ' * (longest_len - this_len) + key + ' : ' + value
    print ''

if __name__ == "__main__":
  main()

@@ -414,21 +414,16 @@
 '%0A    db
-_file
  = anydb
@@ -433,19 +433,15 @@
 pen(
-sys.argv%5B1%5D
+db_file
 , 'r
@@ -456,21 +456,16 @@
 eys = db
-_file
 .keys()%0A
@@ -692,21 +692,16 @@
 loads(db
-_file
 %5Bkey%5D))%0A

Fix a brain-O in the new dump-db.py cvs2svn debug helper app.