Created
July 22, 2008 15:08
-
-
Save earl/1065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# earl, 2008-07-22 | |
from __future__ import with_statement | |
import stringtemplate3, simplejson, sys | |
def main(): | |
with open(sys.argv[1]) as template_file: | |
template = stringtemplate3.StringTemplate(template_file.read()) | |
template.attributes = simplejson.load(sys.stdin) | |
sys.stdout.write(unicode(template).encode('utf-8')) | |
sys.stdout.flush() | |
if __name__ == '__main__': | |
if len(sys.argv) != 2: | |
from sys import stderr as err | |
print >> err, 'Usage: %s template' % (sys.argv[0]) | |
print >> err, 'Renders JSON data from stdin through template to stdout.' | |
sys.exit(64) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment