def from_dict(cls, dic):
        if "judge" in dic:
            judge_type = dic["judge"]["judge_type"]
            if judge_type == "normal":
                judge_method = NormalJudge.from_dict(dic["judge"])
            elif judge_type == "decimal":
                judge_method = DecimalJudge.from_dict(dic["judge"])
            else:
                raise Exception("invalid judge type")
        else:
            judge_method = NormalJudge()

        return Metadata(problem=Problem.from_dict(dic["problem"]),
                        code_filename=dic["code_filename"],
                        sample_in_pattern=dic["sample_in_pattern"],
                        sample_out_pattern=dic["sample_out_pattern"],
                        lang=Language.from_name(dic["lang"]),
                        judge_method=judge_method)
Exemple #2
0
    def from_dict(cls, dic):
        if "judge" in dic:
            judge_type = dic["judge"]["judge_type"]
            if judge_type == "normal":
                judge_method = NormalJudge.from_dict(dic["judge"])
            elif judge_type == "decimal":
                judge_method = DecimalJudge.from_dict(dic["judge"])
            elif judge_type == "multisolution":
                judge_method = MultiSolutionJudge()
            elif judge_type == "interactive":
                judge_method = InteractiveJudge()
            else:
                raise NoJudgeTypeException()
        else:
            judge_method = NormalJudge()

        return Metadata(problem=Problem.from_dict(dic["problem"]),
                        code_filename=dic["code_filename"],
                        sample_in_pattern=dic["sample_in_pattern"],
                        sample_out_pattern=dic["sample_out_pattern"],
                        lang=Language.from_name(dic["lang"]),
                        judge_method=judge_method)