MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / valueTreeToString

Function valueTreeToString

edrav2/eprj/jsoncpp/test/pyjsontestrunner.py:25–51  ·  view source on GitHub ↗
(fout, value, path = '.')

Source from the content-addressed store, hash-verified

23rewrite_actual_path = base_path + '.actual-rewrite'
24
25def valueTreeToString(fout, value, path = '.'):
26 ty = type(value)
27 if ty is types.DictType:
28 fout.write('%s={}\n' % path)
29 suffix = path[-1] != '.' and '.' or ''
30 names = value.keys()
31 names.sort()
32 for name in names:
33 valueTreeToString(fout, value[name], path + suffix + name)
34 elif ty is types.ListType:
35 fout.write('%s=[]\n' % path)
36 for index, childValue in zip(xrange(0,len(value)), value):
37 valueTreeToString(fout, childValue, path + '[%d]' % index)
38 elif ty is types.StringType:
39 fout.write('%s="%s"\n' % (path,value))
40 elif ty is types.IntType:
41 fout.write('%s=%d\n' % (path,value))
42 elif ty is types.FloatType:
43 fout.write('%s=%.16g\n' % (path,value))
44 elif value is True:
45 fout.write('%s=true\n' % path)
46 elif value is False:
47 fout.write('%s=false\n' % path)
48 elif value is None:
49 fout.write('%s=null\n' % path)
50 else:
51 assert False and "Unexpected value type"
52
53def parseAndSaveValueTree(input, actual_path):
54 root = json.loads(input)

Callers 1

parseAndSaveValueTreeFunction · 0.85

Calls 7

xrangeFunction · 0.85
lenFunction · 0.85
typeClass · 0.50
zipClass · 0.50
writeMethod · 0.45
keysMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected