parse problem code template

This commit is contained in:
virusdefender
2017-11-26 13:42:38 +08:00
parent 324535474e
commit 945ea5e4e0
4 changed files with 128 additions and 4 deletions

10
problem/utils.py Normal file
View File

@@ -0,0 +1,10 @@
import re
def parse_problem_template(template_str):
prepend = re.findall("//PREPEND BEGIN\n([\s\S]+?)//PREPEND END", template_str)
template = re.findall("//TEMPLATE BEGIN\n([\s\S]+?)//TEMPLATE END", template_str)
append = re.findall("//APPEND BEGIN\n([\s\S]+?)//APPEND END", template_str)
return {"prepend": prepend[0] if prepend else "",
"template": template[0] if template else "",
"append": append[0] if append else ""}