1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
hipchat-emoticons-for-all/assets/build-assets.py

26 lines
719 B
Python
Raw Normal View History

import json, os
from base64 import b64encode
from glob import glob
def get_filename(path):
return path.replace('assets/', "").replace('.png', '')
files = glob('assets/*.png')
image_bin = []
for filename in files:
with open(filename, 'rb') as file:
image_bin.append({ get_filename(filename): "data:image/png;base64,"+ (str(b64encode(file.read()))[2:-1])})
image_decoder = {"sites":image_bin}
image_decoder_json = json.dumps(image_decoder, indent=2, sort_keys=True)
js_file = None
with open('src/image-decoder.js', "r") as file:
js_file = file.read()
js_file = js_file.replace("%image_decoder%", image_decoder_json)
with open('build/image-decoder.js', 'w') as file:
file.write(js_file)