[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/FileStorage/fsdump.py Size info for object records was added. Also use enumerate() builtin.

Dmitry Vasiliev dima at hlabs.spb.ru
Thu Feb 3 06:19:45 EST 2005


Log message for revision 29027:
  Size info for object records was added. Also use enumerate() builtin.
  

Changed:
  U   ZODB/trunk/src/ZODB/FileStorage/fsdump.py

-=-
Modified: ZODB/trunk/src/ZODB/FileStorage/fsdump.py
===================================================================
--- ZODB/trunk/src/ZODB/FileStorage/fsdump.py	2005-02-03 10:43:25 UTC (rev 29026)
+++ ZODB/trunk/src/ZODB/FileStorage/fsdump.py	2005-02-03 11:19:45 UTC (rev 29027)
@@ -21,9 +21,8 @@
 from ZODB.tests.StorageTestBase import zodb_unpickle
 
 def fsdump(path, file=None, with_offset=1):
-    i = 0
     iter = FileIterator(path)
-    for trans in iter:
+    for i, trans in enumerate(iter):
         if with_offset:
             print >> file, "Trans #%05d tid=%016x time=%s offset=%d" % \
                   (i, u64(trans.tid), str(TimeStamp(trans.tid)), trans._pos)
@@ -32,12 +31,13 @@
                   (i, u64(trans.tid), str(TimeStamp(trans.tid)))
         print >> file, "\tstatus=%s user=%s description=%s" % \
               (`trans.status`, trans.user, trans.description)
-        j = 0
-        for rec in trans:
+        for j, rec in enumerate(trans):
             if rec.data is None:
                 fullclass = "undo or abort of object creation"
+                size = ""
             else:
                 modname, classname = get_pickle_metadata(rec.data)
+                size = " size=%d" % len(rec.data)
                 fullclass = "%s.%s" % (modname, classname)
                 # FIXME: Is this used?
                 # special case for testing purposes
@@ -45,20 +45,18 @@
                     obj = zodb_unpickle(rec.data)
                     fullclass = "%s %s" % (fullclass, obj.value)
             if rec.version:
-                version = "version=%s " % rec.version
+                version = " version=%s" % rec.version
             else:
-                version = ''
+                version = ""
             if rec.data_txn:
                 # XXX It would be nice to print the transaction number
                 # (i) but it would be too expensive to keep track of.
-                bp = "bp=%016x" % u64(rec.data_txn)
+                bp = " bp=%016x" % u64(rec.data_txn)
             else:
                 bp = ""
-            print >> file, "  data #%05d oid=%016x %sclass=%s %s" % \
-                  (j, u64(rec.oid), version, fullclass, bp)
-            j += 1
+            print >> file, "  data #%05d oid=%016x%s%s class=%s%s" % \
+                  (j, u64(rec.oid), version, size, fullclass, bp)
         print >> file
-        i += 1
     iter.close()
 
 def fmt(p64):



More information about the Zodb-checkins mailing list