quizcomp.converter.json

 1import typing
 2
 3import edq.util.json
 4
 5import quizcomp.converter.converter
 6import quizcomp.model.quiz
 7
 8class JSONConverter(quizcomp.converter.converter.Converter):
 9    """
10    A converter to convert a quiz to JSON.
11    The produced JSON will be more raw (less polished) than JSONTemplateConverter.
12    """
13
14    def __init__(self, **kwargs: typing.Any) -> None:
15        super().__init__(**kwargs)
16
17    def convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: typing.Any) -> str:
18        return edq.util.json.dumps(variant.to_dict(), indent = 4)
class JSONConverter(quizcomp.converter.converter.Converter):
 9class JSONConverter(quizcomp.converter.converter.Converter):
10    """
11    A converter to convert a quiz to JSON.
12    The produced JSON will be more raw (less polished) than JSONTemplateConverter.
13    """
14
15    def __init__(self, **kwargs: typing.Any) -> None:
16        super().__init__(**kwargs)
17
18    def convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: typing.Any) -> str:
19        return edq.util.json.dumps(variant.to_dict(), indent = 4)

A converter to convert a quiz to JSON. The produced JSON will be more raw (less polished) than JSONTemplateConverter.

JSONConverter(**kwargs: Any)
15    def __init__(self, **kwargs: typing.Any) -> None:
16        super().__init__(**kwargs)
def convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: Any) -> str:
18    def convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: typing.Any) -> str:
19        return edq.util.json.dumps(variant.to_dict(), indent = 4)

Convert the given variant to the converter's target format and return the converted artifact.