Skip to content

Instantly share code, notes, and snippets.

@alexmagaddino
Last active July 13, 2020 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexmagaddino/234e2dddac28dc0f82a128acdb947f83 to your computer and use it in GitHub Desktop.
Save alexmagaddino/234e2dddac28dc0f82a128acdb947f83 to your computer and use it in GitHub Desktop.
import json
from pathlib import Path
def normalized(name):
return (name.replace("-", "_")).lower()
def prettyHex(num):
return str(hex(num)).replace("0x","")
input = open(Path(__file__).parent / "selection.json")
welcome = json.loads(input.read())
ris = ""
for icon in welcome["icons"]:
code = icon["properties"]["code"]
name = icon["properties"]["name"]
rr = '"' + prettyHex(code) + '" -> R.drawable.' + normalized(name) + "\n"
ris += rr
print(ris)
output = open(Path('Desktop') / "export.txt", "w")
output.write(ris)
print("Output write in export.txt")
input.close()
output.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment