oh yeah let's not crash on basic mistakes
This commit is contained in:
parent
c39c7cf20c
commit
cd52d0be38
7
noble.py
7
noble.py
@ -1,13 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
import pystache, sys, yaml
|
||||
|
||||
def DieIf(cond, *message, **kwargs):
|
||||
if cond:
|
||||
print(sys.argv[0] + ":", *message, **kwargs)
|
||||
sys.exit(1)
|
||||
|
||||
inData = yaml.safe_load(sys.stdin.read())
|
||||
DieIf(len(sys.argv)==1, "no template specified")
|
||||
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)]:
|
||||
DieIf(i not in inData, "missing color %s" % i)
|
||||
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]
|
||||
|
Loading…
Reference in New Issue
Block a user