mirror of
https://github.com/ThunderEX/py-kms.git
synced 2025-04-18 07:44:00 +03:00
fix part of issue #28: fix debug output of CtxItemArray, especially in python 2
This commit is contained in:
parent
34ac3aac71
commit
6e1550d875
13
rpcBind.py
13
rpcBind.py
@ -62,8 +62,17 @@ class CtxItemArray:
|
||||
else:
|
||||
return super(CtxItemArray, self).__str__()
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.data)
|
||||
def dump(self, msg=None, indent=0):
|
||||
if msg is None: msg = self.__class__.__name__
|
||||
ind = ' '*indent
|
||||
print("\n%s" % (msg,))
|
||||
item_cnt = int( (len(self) + len(CtxItem()) - 1) / len(CtxItem()) ) # ceiling
|
||||
for i in range(item_cnt):
|
||||
if hasattr(self[i], 'dump'):
|
||||
self[i].dump('%s%s:{' % (ind,i), indent = indent + 4)
|
||||
print("%s}" % ind)
|
||||
else:
|
||||
print("%s%s: {%r}" % (ind,i,self[i]))
|
||||
|
||||
def __getitem__(self, i):
|
||||
return CtxItem(self.data[(len(CtxItem()) * i):])
|
||||
|
@ -555,13 +555,13 @@ class Structure:
|
||||
def dump(self, msg = None, indent = 0):
|
||||
if msg is None: msg = self.__class__.__name__
|
||||
ind = ' '*indent
|
||||
print("\n%s" % (msg))
|
||||
print("\n%s" % (msg,))
|
||||
fixedFields = []
|
||||
for field in self.commonHdr+self.structure:
|
||||
i = field[0]
|
||||
if i in self.fields:
|
||||
fixedFields.append(i)
|
||||
if isinstance(self[i], Structure):
|
||||
if hasattr(self[i], 'dump'):
|
||||
self[i].dump('%s%s:{' % (ind,i), indent = indent + 4)
|
||||
print("%s}" % ind)
|
||||
else:
|
||||
@ -570,7 +570,7 @@ class Structure:
|
||||
# print them
|
||||
remainingFields = list(set(self.fields) - set(fixedFields))
|
||||
for i in remainingFields:
|
||||
if isinstance(self[i], Structure):
|
||||
if hasattr(self[i], 'dump'):
|
||||
self[i].dump('%s%s:{' % (ind,i), indent = indent + 4)
|
||||
print("%s}" % ind)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user