Browse Source

oh yeah let's not crash on basic mistakes

master
whut 1 year ago
parent
commit
cd52d0be38
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      noble.py

+ 7
- 0
noble.py View File

@@ -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…
Cancel
Save