ChatON:P3:meta json to hpp: Retain esc seqs and more kv pairs
Use repr to retain the escape sequences in the read string. And parallely skip the single quote around strings wrt repr. Bring in more k-v pairs wrt chaton_meta.json
This commit is contained in:
parent
078e04d32b
commit
7b5fb0a2fa
1 changed files with 22 additions and 6 deletions
|
@ -7,15 +7,31 @@ import json
|
|||
|
||||
|
||||
def kv(j, tmpl, k1, k2, comma):
|
||||
print("\t\t{{ \"{}\", \"{}\" }}{}".format("{}-{}".format(k1,k2), j[tmpl][k1][k2], comma))
|
||||
print("\t\t{{ \"{}\", \"{}\" }}{}".format("{}-{}".format(k1,k2), repr(j[tmpl][k1][k2])[1:-1], comma))
|
||||
|
||||
|
||||
fp=open(sys.argv[1])
|
||||
j=json.load(fp)
|
||||
print("{")
|
||||
for tmpl in j:
|
||||
print("\t{{ \"{}\", {{".format(tmpl))
|
||||
kv(j, tmpl, "global", "begin", ",")
|
||||
kv(j, tmpl, "global", "end", ",")
|
||||
print("\t}},")
|
||||
|
||||
print("\t{{ \"{}\", {{".format(tmpl))
|
||||
|
||||
kv(j, tmpl, "global", "begin", ",")
|
||||
kv(j, tmpl, "global", "end", ",")
|
||||
|
||||
kv(j, tmpl, "system", "begin", ",")
|
||||
kv(j, tmpl, "system", "prefix", ",")
|
||||
kv(j, tmpl, "system", "suffix", ",")
|
||||
kv(j, tmpl, "system", "end", ",")
|
||||
|
||||
kv(j, tmpl, "user", "begin", ",")
|
||||
kv(j, tmpl, "user", "prefix", ",")
|
||||
kv(j, tmpl, "user", "suffix", ",")
|
||||
kv(j, tmpl, "user", "end", ",")
|
||||
|
||||
kv(j, tmpl, "assistant", "begin", ",")
|
||||
kv(j, tmpl, "assistant", "prefix", ",")
|
||||
kv(j, tmpl, "assistant", "suffix", ",")
|
||||
kv(j, tmpl, "assistant", "end", ",")
|
||||
|
||||
print("\t}},")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue