Created
September 3, 2018 23:02
-
-
Save metaphox/7b3fcec79517b12aec20b9b46009bd3a 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
_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