+def truncate_result(result, length=50):
+ self = result
+ code = self['code']
+ result = "[MFresult {} (code={})".format(_messages_.get(code, "???"), code)
+ if code == 0:
+ value = self['value']
+ if isinstance(value, list):
+ result += " [value=list with {} elts]".format(len(value))
+ elif isinstance(value, dict):
+ result += " [value=dict with keys {}]".format(value.keys())
+ else:
+ result += " [value={}: {}]".format(type(value).__name__, value)
+ elif 'output' in self:
+ result += " [output={}]".format(self['output'])
+ else:
+ result += "<no output>"
+ result += "]"
+ return truncate(result, 60)
+