Preserve data type when constructing new container
Ensure that we use the original object to create the new container to place the formatted contents into thus ensuring that we treat the objects passed in a pure duck-typing manner rather than assuming they are basic python data types. Change-Id: Ib0ccea728f08ff4cf43b8ccc92477b7c46296ce9
This commit is contained in:
parent
74d10e4059
commit
7782cac60e
|
@ -45,11 +45,11 @@ def deep_format(obj, paramdict, allow_empty=False):
|
|||
missing_key, obj, pformat(paramdict))
|
||||
raise JenkinsJobsException(desc)
|
||||
elif isinstance(obj, list):
|
||||
ret = []
|
||||
ret = type(obj)()
|
||||
for item in obj:
|
||||
ret.append(deep_format(item, paramdict, allow_empty))
|
||||
elif isinstance(obj, dict):
|
||||
ret = {}
|
||||
ret = type(obj)()
|
||||
for item in obj:
|
||||
try:
|
||||
ret[CustomFormatter(allow_empty).format(item, **paramdict)] = \
|
||||
|
|
Loading…
Reference in New Issue