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

33 lines
801 B
Python
Raw Normal View History

import json
from glob import glob
ASSETS_URL="https://raw.githubusercontent.com/RealOrangeOne/hipchat-emoticons-for-all/master/assets/"
def get_icon_name(path):
2015-08-25 16:09:58 +01:00
return get_filename(path).replace('.png', '').replace('.gif', '')
def get_filename(path):
return path.replace('assets/', '')
2015-08-25 16:59:23 +01:00
files = glob('assets/*.png') + glob('assets/*.gif')
images = []
for filename in files:
images.append({get_icon_name(filename): ASSETS_URL + get_filename(filename)})
2015-08-25 16:09:58 +01:00
image_decoder = {"images":images}
image_decoder_json = json.dumps(image_decoder, indent=2, sort_keys=True)
js_file = None
with open('src/injector.js', "r") as file:
js_file = file.read()
js_file = js_file.replace("%image_decoder%", image_decoder_json)
with open('build/injector.js', 'w') as file:
file.write(js_file)