Skip to content

Commit

Permalink
Add OIJ contest type
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Apr 21, 2024
1 parent 1eecdff commit 0294c36
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sinol_make/contest_types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sinol_make.contest_types.default import DefaultContest
from sinol_make.contest_types.icpc import ICPCContest
from sinol_make.contest_types.oi import OIContest
from sinol_make.contest_types.oij import OIJContest
from sinol_make.helpers.package_util import get_config
from sinol_make.interfaces.Errors import UnknownContestType

Expand All @@ -15,5 +16,7 @@ def get_contest_type():
return OIContest()
elif contest_type == "icpc":
return ICPCContest()
elif contest_type == "oij":
return OIJContest()
else:
raise UnknownContestType(f'Unknown contest type "{contest_type}"')
32 changes: 32 additions & 0 deletions src/sinol_make/contest_types/oij.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import argparse

from sinol_make import util
from sinol_make.helpers import package_util
from sinol_make.contest_types.default import DefaultContest


class OIJContest(DefaultContest):
"""
Contest type for Polish Junior Olympiad in Informatics.
"""

def get_type(self) -> str:
return "oij"

def argument_overrides(self, args: argparse.Namespace) -> argparse.Namespace:
"""
Add arguments for features required by OIJ contest
"""
args.export_ocen = True
return args

def verify_pre_gen(self):
"""
Verify if scores sum up to 100.
"""
config = package_util.get_config()
if 'scores' not in config:
util.exit_with_error("Scores are not defined in config.yml.")
total_score = sum(config['scores'].values())
if total_score != 100:
util.exit_with_error(f"Total score in config is {total_score}, but should be 100.")

0 comments on commit 0294c36

Please sign in to comment.