def print_slot_map(slots):
def stars(schema):
if schema == None:
return "-"
s = json.dumps(schema)
return s if len(s) <= 10 else "*****"
def yesno(flag):
return "Yes" if flag else "No"
def glue(a, b):
if len(a) > len(b):
b += [[None] * 3] * (len(a) - len(b))
elif len(a) < len(b):
a += [[None] * 4] * (len(b) - len(a))
return [ x + [None] + y for x,y in zip(a, b) ]
left = [ [x.slot,stars(x.schema),x.action,yesno(x.recordsets)]
for x in slots if x.slot % 2 == 0 ]
right = [ [x.slot,stars(x.schema),yesno(x.recordsets)]
for x in slots if x.slot % 2 == 1 ]
headers = ["Slot","Schema","Action","Recordsets","","Slot","Schema","Recordsets"]
print tabulate(glue(left, right), headers=headers)
评论列表
文章目录