X on py3 porting
Works, but needs pygolang@c9648c44
... | ... | @@ -65,7 +65,7 @@ TODO also protect txn record by hash. |
from __future__ import print_function | ||
from zodbtools.util import ashex, fromhex, sha1, txnobjv, parse_tidrange, TidRangeInvalid, \ | ||
storageFromURL, hashRegistry, asbinstream | ||
from ZODB._compat import loads, _protocol, BytesIO | ||
from ZODB._compat import loads, _protocol | ||
from zodbpickle.slowpickle import Pickler as pyPickler | ||
import pickletools | ||
from ZODB.interfaces import IStorageTransactionInformation | ||
... | ... | @@ -74,6 +74,7 @@ from zope.interface import implementer |
import sys | ||
import logging as log | ||
import re | ||
from io import BytesIO, StringIO | ||
from golang.gcompat import qq | ||
from golang import func, defer, strconv, b | ||
... | ... | @@ -122,9 +123,9 @@ def zodbdump(stor, tidmin, tidmax, hashonly=False, pretty='raw', out=asbinstream |
else: | ||
out.write(b"extension\n") | ||
extf = BytesIO(rawext) | ||
disf = BytesIO() | ||
disf = StringIO() | ||
pickletools.dis(extf, disf) | ||
out.write(indent(disf.getvalue(), " ")) | ||
out.write(b(indent(disf.getvalue(), " "))) | ||
extra = extf.read() | ||
if len(extra) > 0: | ||
out.write(b" + extra data %s\n" % qq(extra)) | ||
... | ... | @@ -161,10 +162,10 @@ def zodbdump(stor, tidmin, tidmax, hashonly=False, pretty='raw', out=asbinstream |
elif pretty == 'zpickledis': | ||
# https://github.com/zopefoundation/ZODB/blob/5.6.0-55-g1226c9d35/src/ZODB/serialize.py#L24-L29 | ||
dataf = BytesIO(obj.data) | ||
disf = BytesIO() | ||
disf = StringIO() | ||
pickletools.dis(dataf, disf) # class | ||
pickletools.dis(dataf, disf) # state | ||
out.write(indent(disf.getvalue(), " ")) | ||
out.write(b(indent(disf.getvalue(), " "))) | ||
extra = dataf.read() | ||
if len(extra) > 0: | ||
out.write(b" + extra data %s\n" % qq(extra)) | ||
... | ... | @@ -432,7 +433,7 @@ class DumpReader(object): |
else: | ||
size = int(m.group('size')) | ||
hashfunc = m.group('hashfunc') | ||
hashfunc = b(m.group('hashfunc')) | ||
hashok = fromhex(m.group('hash')) | ||
hashonly = m.group('hashonly') is not None | ||
data = None # see vvv | ||
... | ... | @@ -550,7 +551,7 @@ class ObjectCopy(Object): |
# ObjectData represents record with object data. | ||
class ObjectData(Object): | ||
# .data HashOnly | bytes | ||
# .hashfunc str hash function used for integrity | ||
# .hashfunc bstr hash function used for integrity | ||
|
||
# .hash_ bytes hash of the object's data | ||
def __init__(self, oid, data, hashfunc, hash_): | ||
super(ObjectData, self).__init__(oid) | ||
... | ... |
-
mentioned in commit nexedi/slapos@b6ff149e
-
mentioned in merge request nexedi/zodbtools!23 (merged)
-
mentioned in commit nexedi/zodbtools@7ae5ff82