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