You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
1.1 KiB

def validate_data_not_empty(input_data):
"""
工具方法:根据输入数据校验数据是否不为None和''
:param input_data: 输入数据
:return: 校验结果
"""
return input_data is not None and input_data != ''
#判断节点层级和名称
def find_title_and_path(data, key, path=None, level=0):
if path is None:
path = []
if 'key' in data and data['key'] == key:
# 当前层级的 title 加入路径
path.append(data['title'])
return data['title'], level, path
elif 'children' in data:
for child in data['children']:
title, child_level, updated_path = find_title_and_path(child, key, path + [data['title']], level + 1)
if title is not None:
return title, child_level, updated_path
return None, -1, path
#拓展字符串长度
def process_string(s):
if len(s) < 65 and len(s) > 55 :
return s + "..."
elif len(s) < 55 :
return s + ". ."
elif len(s) > 90:
return s[:90]+ "..."
else:
return s