Skip to content

Instantly share code, notes, and snippets.

@metaphox
Created September 3, 2018 23:02
Show Gist options
  • Save metaphox/7b3fcec79517b12aec20b9b46009bd3a to your computer and use it in GitHub Desktop.
Save metaphox/7b3fcec79517b12aec20b9b46009bd3a to your computer and use it in GitHub Desktop.
_DEFAULTS = [
a : '123',
b : '456',
c : []
]
def foo = [ a : '789', c : ['000', '111', 222] ]
def getTemplate() {
return """
a : @A@,
b : @B@,
c : [
@C@
]
"""
}
def setSetupPyParams( params ) {
if (params) {
params = _DEFAULTS + params
}else{
params = _DEFAULTS
}
String template = getTemplate()
for (item in params){
key = '@' + item.key.toUpperCase() + '@'
value = item.value
if (value instanceof List) {
value = value.join(',')
}
template = template.replace(key, value)
}
return template
}
setSetupPyParams( foo )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment