新增两个database_tools_2中的函数, idIDpart判断一个列表是不是题号列表, findxiaobenIDs获取指定目录下的指定年级的校本题目ID
This commit is contained in:
parent
2bb0f464fd
commit
4934e2df3e
|
|
@ -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用.")
|
||||
Reference in New Issue