22 lines
745 B
Python
Executable File
22 lines
745 B
Python
Executable File
#!/usr/bin/env python3
|
|
import pystache, sys, yaml
|
|
|
|
inData = yaml.safe_load(sys.stdin.read())
|
|
template = open(sys.argv[1], 'r').read()
|
|
data = {'scheme-name': inData.get('scheme', 'Untitled'),
|
|
'scheme-author': inData.get('author', 'Anonymous'),
|
|
'scheme-slug': '<stdin>'}
|
|
|
|
for i in ["base%02X" % x for x in range(16)]:
|
|
colorHex = [inData[i][x*2:x*2+2] for x in range(3)]
|
|
color = [int(x, 16) for x in colorHex]
|
|
data[i + "-hex"] = inData[i]
|
|
data[i + "-hex-bgr"] = "".join(colorHex[::-1])
|
|
for c in range(3):
|
|
comp = "rgb"[c]
|
|
data[i + "-hex-" + comp] = colorHex[c]
|
|
data[i + "-rgb-" + comp] = color[c]
|
|
data[i + "-dec-" + comp] = color[c] / 255.0
|
|
|
|
print(pystache.render(template, data))
|