Fix the 'configuration._' not defined error when not provide '_' parameter.
There will be an error when we don't provide _
in webrunner.
The instance-parameter:configuration
is something like '''!py!{'full_address_list': [], '_': '{}'}'''
This commit process it by these steps:
- Remove the
!py
prefix bystr[4:]
. - Use double quotes replace single quotes within the str.
- Get the dict
{'full_address_list': [], '_': '{}'}
- Get the value of the
'_'
key, in this case, it is a string"{}"
. Usejson
to convert it to a dict{}
.
Notes:
- Use
eval
orast.literal_eval
can do it in 1 or 2 steps. But it is unsafe and can not process json string which containstrue
,false
, etc. - The test suite was passed in here with this commit: Daetalus/slapos@6e15fa38 . The commit includes in here contains some formatting.
Please let me know if there has trouble to hardcode the str[4:]
or there has corner case that I didn't cover.