##// END OF EJS Templates
wireproto: show unknown id and flags in repr(frame)...
Yuya Nishihara -
r37491:7c2c7c74 default
parent child Browse files
Show More
@@ -110,10 +110,13 b' ARGUMENT_RECORD_HEADER = struct.Struct(r'
110 110
111 111 def humanflags(mapping, value):
112 112 """Convert a numeric flags value to a human value, using a mapping table."""
113 namemap = {v: k for k, v in mapping.iteritems()}
113 114 flags = []
114 for val, name in sorted({v: k for k, v in mapping.iteritems()}.iteritems()):
115 val = 1
116 while value >= val:
115 117 if value & val:
116 flags.append(name)
118 flags.append(namemap.get(val, '<unknown 0x%02x>' % val))
119 val <<= 1
117 120
118 121 return b'|'.join(flags)
119 122
@@ -140,7 +143,7 b' class frame(object):'
140 143 payload = attr.ib()
141 144
142 145 def __repr__(self):
143 typename = '<unknown>'
146 typename = '<unknown 0x%02x>' % self.typeid
144 147 for name, value in FRAME_TYPES.iteritems():
145 148 if value == self.typeid:
146 149 typename = name
General Comments 0
You need to be logged in to leave comments. Login now