database_tools中添加寻找下一个空闲题号和寻找下一个空闲题号块的功能
This commit is contained in:
parent
09569f4bdc
commit
a9a51ba0b7
|
|
@ -204,6 +204,21 @@ def spareIDs(dictname): #返回空闲题号
|
|||
return output #返回的是一个多行的字符串, 每一行中含有一个空闲题号的闭区间
|
||||
|
||||
|
||||
def NextSpareID(num,adict): #返回adict中下一个空闲的题号
|
||||
num = int(num)
|
||||
while str(num).zfill(6) in adict:
|
||||
num += 1
|
||||
return num
|
||||
|
||||
def NextSpareIDBlock(num,adict): #返回adict中下一个空闲的题号块
|
||||
start = NextSpareID(num,adict)
|
||||
larger_ID_list = [int(id) for id in adict.keys() if int(id)>start]
|
||||
if larger_ID_list == []:
|
||||
end = 999999
|
||||
else:
|
||||
end = min(larger_ID_list) - 1
|
||||
return str(start)+":"+str(end)
|
||||
|
||||
def GenerateProblemListFromString(data): #从来自.tex文件的字符串生成题目列表, 每个item是一道题目, 新一行的%用作前缀
|
||||
try:
|
||||
data = re.findall(r"\\begin\{document\}([\s\S]*?)\\end\{document\}",data)[0]
|
||||
|
|
|
|||
Reference in New Issue