This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
dongxiaoyan-tsg-autotest/04-CustomLibrary/Library/VerifyPolicy.py

56 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
def get_dict_allkeys(dict_a):
if isinstance(dict_a, dict): # 使用isinstance检测数据类型
# 如果为字典类型则提取key存放到key_list中
for x in range(len(dict_a)):
temp_key = list(dict_a.keys())[x]
temp_value = dict_a[temp_key]
if temp_key.endswith("Id"):
key_list.append(temp_value)
get_dict_allkeys(temp_value) # 自我调用实现无限遍历
elif isinstance(dict_a, list):
# 如果为列表类型则遍历列表里的元素将字典类型的按照上面的方法提取key
for k in dict_a:
if isinstance(k, dict):
for x in range(len(k)):
temp_key = list(k.keys())[x]
temp_value = k[temp_key]
if temp_key.endswith("Id"):
key_list.append(temp_value)
get_dict_allkeys(temp_value) # 自我调用实现无限遍历
return key_list
def VerifyProxy(data,lists):
global key_list
key_list = []
datas = get_dict_allkeys(data)
print(type(datas))
lists=lists.split(",")
print(type(lists))
print("gsd")
datas2=list(map(str,datas))
print(datas2)
print(datas)
print(lists)
if set(datas2) > set(lists):
return "true"
else:
return "flase"
# 判断值是否在列表中
# def VerifyProxy(self,data,lists):
# global key_list
# key_list = []
# datas = Order.get_dict_allkeys(self,data)
# print(type(datas))
# lists=lists.split(",")
# print(type(lists))
# print("gsd")
# datas2=list(map(str,datas))
# print(datas2)
# print(datas)
# print(lists)
# if set(datas2) > set(lists):
# return "true"
# else:
# return "flase"