From 5e9b85b07d31fbbac36d441c38c43d4506345d7e Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Sun, 7 Apr 2024 19:35:42 +0800 Subject: [PATCH] =?UTF-8?q?database=5Ftools=E4=B8=AD=E5=A2=9E=E5=8A=A0gene?= =?UTF-8?q?rate=5Forigin=E5=87=BD=E6=95=B0,=20=E7=94=9F=E6=88=90=E6=9D=A5?= =?UTF-8?q?=E6=BA=90=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index b4270b93..1caaec21 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -917,6 +917,14 @@ def StripSuffix(string, suf_words): #除去字符串前后的空格及suf_words return(string) # 返回处理以后的字符串 +def generate_origin(origin_dict): + data = origin_dict["来源"] + if "题号" in origin_dict: + data = f"{data}试题{origin_dict['题号']}" + if "前序" in origin_dict: + data = f"{data}-改编自{origin_dict['前序']}" + return data + def MatchCondition2024(problem,condition_list): #判断problem这一字典是否符合condition_list中的所有筛选条件 match = True #初始设定符合条件 for field, flag_not, matchexp in condition_list: @@ -924,10 +932,7 @@ def MatchCondition2024(problem,condition_list): #判断problem这一字典是否 if type(problem[field]) == list: data = "\n".join(problem[field]) elif field == "origin": - if "题号" in problem[field]: - data = problem[field]["来源"]+"试题"+str(problem[field]["题号"]).zfill(2) - else: - data = problem[field]["来源"] + data = generate_origin(problem[field]) else: data = str(problem[field]) #至此将每个字段中的内容都转为string if flag_not == False: #表示肯定的筛选