Commit 85d68990 by Tobias Langer

Added utility functions to fiddle around with text in mustache file.

parent 390b3a0e
...@@ -20,6 +20,29 @@ import shutil ...@@ -20,6 +20,29 @@ import shutil
import json import json
import pystache import pystache
class UtilityFunctions(pystache.TemplateSpec):
def Upper(self, text=None):
"""
Capitalize a given token
"""
return lambda txt: txt.upper()
def Lower(self, text=None):
"""
Return the given text in lowercase.
"""
return lambda txt: txt.lower()
def CamelCase(self, text=None):
"""
Capitalize the first letter of the given text.
"""
def _camel(text):
text[0].upper()
return text
return _camel
def query_yes_no(question, default=None): def query_yes_no(question, default=None):
""" """
Queries the user for a decision. Queries the user for a decision.
...@@ -62,7 +85,7 @@ def create_header(headerfile, experiment, destination): ...@@ -62,7 +85,7 @@ def create_header(headerfile, experiment, destination):
""" """
with open(headerfile, 'r') as header_template: with open(headerfile, 'r') as header_template:
template = header_template.read() template = header_template.read()
header_txt = pystache.render(template, experiment) header_txt = pystache.render(template, experiment, UtilityFunctions())
with open(destination, 'w') as header: with open(destination, 'w') as header:
print(header_txt, file=header) print(header_txt, file=header)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment