diff --git a/工具v4/database_tools_2.py b/工具v4/database_tools_2.py index 3d93bec2..21265e25 100644 --- a/工具v4/database_tools_2.py +++ b/工具v4/database_tools_2.py @@ -3156,6 +3156,29 @@ def generate_adaptive_problemIDs(pro_dict,units_list,genre_tuple,diffinterval,me return tiankong_list,xuanze_list +def isIDpart(alist): #判断一个list是不是题号列表 + for item in alist: + if not (type(item) == str and len(item) <= 6 and re.findall(r"\d{6}",item.zfill(6)) != []): + return False + return True + + +def findxiaobenIDs(jsonpath,grade = ""): #根据jsonpath中的校本材料获取grade做过的题目, grade为空则获取所有目录中的题目 + jsonlists = [] + jsonIDs = [] + for loc,dirs,files in os.walk(jsonpath): + if "校本材料.json" in files: + jsonlists.append(os.path.join(loc,"校本材料.json")) + for jsonfile in jsonlists: + jsondict = load_dict(jsonfile)["notes"] + for pid in jsondict: + if pid[1:5] == grade or grade == "": + for part in jsondict[pid]: + if type(jsondict[pid][part]) == list and isIDpart(jsondict[pid][part]): + jsonIDs += jsondict[pid][part].copy() + return jsonIDs + + if __name__ == "__main__": print("数据库工具, import用.") \ No newline at end of file