Commit 809304d1 authored by Kirill Smelkov's avatar Kirill Smelkov

X "B:" indicates ø bucket with k&b, "B" - ø bucket with only keys

parent 63dd361f
......@@ -187,6 +187,9 @@ class Bucket(object):
kvv = ['%s' % k for k in b.keyv]
else:
assert len(b.keyv) == len(b.valuev)
if len(b.keyv) == 0:
kvv = [':']
else:
kvv = ['%s:%s' % (k,v) for (k,v) in zip(b.keyv, b.valuev)]
return "B" + ','.join(kvv)
__repr__ = __str__
......@@ -762,7 +765,10 @@ def TopoEncode(tree, vencode=lambda v: '%d' % v):
tnode = ('T' if isinstance(node, Tree) else 'B')
if isinstance(node, Bucket) and node.valuev is not None:
# bucket with key and values
assert len(node.valuev) == len(node.keyv)
assert len(node.keyv) == len(node.valuev)
if len(node.keyv) == 0:
tnode += ':'
else:
vtxtv = []
for v in node.valuev:
vtxt = vencode(v)
......@@ -820,6 +826,7 @@ def TopoDecode(text, vdecode=int):
withV = (typ is Bucket and ':' in tkeys)
keyv = []
valuev= [] if withV else None
if tkeys != ':': # "B:" indicates ø bucket with values
for tkey in tkeyv:
ktxt = tkey
if withV:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment