git.schokokeks.org
Repositories
Help
Report an Issue
fs-words.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
6a8fba2
Branches
Tags
develop-client_server
master
typescript
fs-words.git
tools
format.py
added correlatives to list; added several tools
fenris
commited
6a8fba2
at 2016-06-15 10:41:10
format.py
Blame
History
Raw
import sys import json def stringify(x): if (x is None): return "null" elif (type(x) == str): return ("\"%s\"" % x) elif (type(x) == list): return ("[%s]" % (",".join(map(lambda y: stringify(y), x)))) else: return str(x) def main(): languages = ["fs","en","af","nl","yi","de","da","nb","sv","nn","is","pg"] data = json.loads(sys.stdin.read()) sys.stdout.write("[\n") first = True for entry in data: if (first): first = False else: sys.stdout.write(",\n") s = "" s += "\t{\n" s += "\t\t%s: %s, %s: %s, %s: %s,\n" % (stringify("type"), stringify(entry["type"]), stringify("description"), stringify(entry["description"]), stringify("tags"), stringify(entry["tags"])) s += "\t\t%s: {%s}\n" % (stringify("translations"), ", ".join(map(lambda language: "%s: %s" % (stringify(language), stringify(entry["translations"][language])), languages))) s += "\t}" sys.stdout.write(s) sys.stdout.write("\n]\n") main()