修改工具v2导入metadata的一处bug
This commit is contained in:
parent
47129199bc
commit
9353176294
|
|
@ -411,7 +411,7 @@ def AppendObjData(prodict,objdict,field_id_and_content): #添加目标编号数
|
|||
|
||||
def AppendUsageData(prodict,field_id_and_content): #添加使用记录数据
|
||||
field,id,content = field_id_and_content
|
||||
lines = [re.sub(r"\s+",r"\t",line.strip()) for line in content.split("\n")]
|
||||
lines = [re.sub(r"\s+",r"\t",line.strip()) for line in content.strip().split("\n")]
|
||||
pending_list = []
|
||||
for line in lines:
|
||||
if not "FORCE" in line.upper():
|
||||
|
|
@ -431,7 +431,7 @@ def AppendUsageData(prodict,field_id_and_content): #添加使用记录数据
|
|||
line = re.sub(r"\s+",r"\t",re.sub(r"FORCE","",line.upper())).strip()
|
||||
prodict[id][field].append(line)
|
||||
print("已于 %s 的 %s 字段执行强制添加, 内容为 %s"%(id,field,line))
|
||||
output = "usages\n\n"
|
||||
output = ""
|
||||
for item in pending_list:
|
||||
id,new,oldlist = item
|
||||
output += id + "\n"
|
||||
|
|
@ -441,6 +441,7 @@ def AppendUsageData(prodict,field_id_and_content): #添加使用记录数据
|
|||
|
||||
def ImportMetadata(prodict,objdict,fieldsdict,metadatafilepath,pendingdatafilepath): #metadata自动修改, 根据字段自适应修改, 参数为题库字典, 目标字典, 字段字典, metadata文本文件路径, 待确定是否替换的内容的存放路径
|
||||
data_to_modify = ObtainDatatoModify(metadatafilepath,fieldsdict)
|
||||
outputstring = "usages\n\n"
|
||||
for item in data_to_modify:
|
||||
field = item[0]
|
||||
if field == "NotAField":
|
||||
|
|
@ -458,11 +459,11 @@ def ImportMetadata(prodict,objdict,fieldsdict,metadatafilepath,pendingdatafilepa
|
|||
feedback = AppendObjData(prodict,objdict,item)
|
||||
elif method == "usageappend":
|
||||
feedback = AppendUsageData(prodict,item)
|
||||
outputstring = feedback[3]
|
||||
SaveTextFile(outputstring,pendingdatafilepath)
|
||||
outputstring += feedback[3]
|
||||
elif method == "fixed":
|
||||
print("字段 %s 不可按此方式修改"%field)
|
||||
return feedback # 已在数据库中修改, 之后需要将数据库写入一次, 返回1表示字段名有误, 返回其他表示成功进行了修改
|
||||
SaveTextFile(outputstring,pendingdatafilepath)
|
||||
return outputstring # 已在数据库中修改, 之后需要将数据库写入一次, 返回1表示字段名有误, 返回其他表示成功进行了修改
|
||||
|
||||
def parseUsage(usagestring): #对单行usage信息进行分词
|
||||
usagedict = {}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ fieldsdict = load_dict("../题库0.3/ProblemFields.json")
|
|||
prodict = load_dict("../题库0.3/Problems.json")
|
||||
objdict = load_dict("../题库0.3/LessonObj.json")
|
||||
|
||||
ModifyMetadata(prodict,objdict,fieldsdict,metadatafilepath,pendingdatafilepath)
|
||||
ImportMetadata(prodict,objdict,fieldsdict,metadatafilepath,pendingdatafilepath)
|
||||
save_dict(prodict,"../题库0.3/Problems.json")
|
||||
|
||||
|
|
|
|||
Reference in New Issue