[skip e2e] Add new func on utils (#14993)

Signed-off-by: wangting0128 <ting.wang@zilliz.com>
pull/15002/head
wt 2022-01-07 14:05:35 +08:00 committed by GitHub
parent 7b3b2ba94a
commit 701105a6b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -371,3 +371,20 @@ def get_image_tag():
except:
print("Can not get the tag list")
return "master-latest"
def dict_recursive_key(_dict, key=None):
if isinstance(_dict, dict):
key_list = list(_dict.keys())
for k in key_list:
if isinstance(_dict[k], dict):
dict_recursive_key(_dict[k], key)
if key is None:
if _dict[k] is key:
del _dict[k]
else:
if _dict[k] == key:
del _dict[k]
return _dict