Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Tobias Langer
/
experiment
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
85d68990
authored
Oct 07, 2016
by
Tobias Langer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added utility functions to fiddle around with text in mustache file.
parent
390b3a0e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletions
+24
-1
generate.py
+24
-1
No files found.
generate.py
View file @
85d68990
...
...
@@ -20,6 +20,29 @@ import shutil
import
json
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
):
"""
Queries the user for a decision.
...
...
@@ -62,7 +85,7 @@ def create_header(headerfile, experiment, destination):
"""
with
open
(
headerfile
,
'r'
)
as
header_template
:
template
=
header_template
.
read
()
header_txt
=
pystache
.
render
(
template
,
experiment
)
header_txt
=
pystache
.
render
(
template
,
experiment
,
UtilityFunctions
()
)
with
open
(
destination
,
'w'
)
as
header
:
print
(
header_txt
,
file
=
header
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment