diff --git a/scripts/mustache.hy b/scripts/mustache.hy deleted file mode 100644 index 187bdcb..0000000 --- a/scripts/mustache.hy +++ /dev/null @@ -1,16 +0,0 @@ -(import [json [loads]]) -(import [sys [argv stdin]]) -(import [pystache [render]]) - -(defn slurp [filename] - (try - (.read (apply open [filename "r"] {"encoding" "utf-8"})) - (catch [e Exception] - ""))) - -(if (= __name__ "__main__") - (let [[template (-> (get argv 1) - slurp)] - [data (-> (.read stdin) - loads)]] - (print (render template data)))) diff --git a/setup.py b/setup.py index 10a51df..721b8fa 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name='tildetown', - version='0.0.1', + version='0.0.2', description='python stuf for tilde.town', url='https://github.com/tildetown/tildetown-scripts', author='vilmibm shaksfrpease', @@ -18,5 +18,5 @@ setup( ], keywords='community', packages=['tildetown'], - install_requires = ['pyhocon==0.3.10', 'sh==1.11', 'Flask==0.10.1', 'requests==2.7.0'], + install_requires = ['pyhocon==0.3.10', 'sh==1.11', 'Flask==0.10.1', 'requests==2.7.0', 'pystache==0.5.4'], ) diff --git a/tildetown/mustache.py b/tildetown/mustache.py new file mode 100644 index 0000000..b909122 --- /dev/null +++ b/tildetown/mustache.py @@ -0,0 +1,12 @@ +from json import loads +from sys import argv,stdin + +from pystache import render + +from tildetown.util import slurp + +if __name__ == '__main__': + template = slurp(argv[1]) + data = loads(stdin.read()) + print(render(template, data)) +