support fps problems import; fix qduoj problems import

This commit is contained in:
virusdefender
2018-01-07 14:37:14 +08:00
parent 79724b0463
commit 82890a92b4
8 changed files with 483 additions and 119 deletions

View File

@@ -1,5 +1,17 @@
import re
TEMPLATE_BASE = """//PREPEND BEGIN
{}
//PREPEND END
//TEMPLATE BEGIN
{}
//TEMPLATE END
//APPEND BEGIN
{}
//APPEND END"""
def parse_problem_template(template_str):
prepend = re.findall("//PREPEND BEGIN\n([\s\S]+?)//PREPEND END", template_str)
@@ -8,3 +20,7 @@ def parse_problem_template(template_str):
return {"prepend": prepend[0] if prepend else "",
"template": template[0] if template else "",
"append": append[0] if append else ""}
def build_problem_template(prepend, template, append):
return TEMPLATE_BASE.format(prepend, template, append)