提交 49c6f6f5 编写于 作者: 泰斯特Test's avatar 泰斯特Test

[refact]支持对非json格式返回的正则校验

上级 5e381ee2
......@@ -219,12 +219,14 @@ def dict_get(dic, locators, default=None):
'''
if not isinstance(dic, dict):
if isinstance(dic, str) and len(locators) == 1 and is_slice_expression(locators[0]):
slice_indexes = locators[0].split(':')
start_index = int(slice_indexes[0]) if slice_indexes[0] else None
end_index = int(slice_indexes[-1]) if slice_indexes[-1] else None
value = dic[start_index:end_index]
return value
if isinstance(dic, str):
if len(locators) == 1 and is_slice_expression(locators[0]):
slice_indexes = locators[0].split(':')
start_index = int(slice_indexes[0]) if slice_indexes[0] else None
end_index = int(slice_indexes[-1]) if slice_indexes[-1] else None
value = dic[start_index:end_index]
return value
return dic
return default
if dic == {} or len(locators) < 1:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册