1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 23:08:14 +00:00
trezor-firmware/tools/codegen/gen_nem_mosaics.py

49 lines
1006 B
Python
Raw Normal View History

#!/usr/bin/env python3
import json
def format_str(value):
return '"' + value + '"'
def format_primitive(value):
if isinstance(value, int):
return value
elif isinstance(value, str):
return format_str(value)
elif isinstance(value, list):
return value
else:
raise TypeError
fields = [
2018-07-31 09:35:09 +00:00
"name",
"ticker",
"namespace",
"mosaic",
"divisibility",
"levy",
"fee",
"levy_namespace",
"levy_mosaic",
"networks",
]
2018-07-31 09:35:09 +00:00
mosaics = json.load(open("../../vendor/trezor-common/defs/nem/nem_mosaics.json", "r"))
2018-07-31 09:35:09 +00:00
print(
"# generated using gen_nem_mosaics.py from trezor-common nem_mosaics.json - do not edit directly!"
)
print("")
print("mosaics = [")
for m in mosaics:
2018-07-31 09:35:09 +00:00
print(" {")
for name in fields:
if name in m:
2018-07-31 09:35:09 +00:00
print(" %s: %s," % (format_str(name), format_primitive(m[name])))
# else:
# print(' %s: None,' % format_str(name))
2018-07-31 09:35:09 +00:00
print(" },")
print("]")