瀏覽代碼

oh yeah let's not crash on basic mistakes

master
whut 1 年之前
父節點
當前提交
cd52d0be38
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. +7
    -0
      noble.py

+ 7
- 0
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…
取消
儲存