tdb: Add simple reimplementation of tdbdump in Python as an example of the tdb Python...
authorJelmer Vernooij <jelmer@samba.org>
Thu, 10 Jan 2008 20:44:38 +0000 (21:44 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 10 Jan 2008 22:41:14 +0000 (23:41 +0100)
source/lib/tdb/python/tdbdump.py [new file with mode: 0644]

diff --git a/source/lib/tdb/python/tdbdump.py b/source/lib/tdb/python/tdbdump.py
new file mode 100644 (file)
index 0000000..d759d77
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/python
+# Trivial reimplementation of tdbdump in Python
+
+import tdb, sys
+
+if len(sys.argv) < 2:
+    print "Usage: tdbdump.py <tdb-file>"
+    sys.exit(1)
+
+db = tdb.Tdb(sys.argv[1])
+for (k, v) in db.iteritems():
+    print "{\nkey(%d) = %r\ndata(%d) = %r\n}" % (len(k), k, len(v), v)