def add_new_format(self, format_name, format_label, generator_class, is_default=False):
        """Adds a new format->generator mapping to the collection

        args:
            format_name: unique name to identify the format
            format_label: label to be displayed to the user
            generator_class: child class of .repeater_generators.BasePayloadGenerator

        kwargs:
            is_default: True if the format_name should be default format

        exceptions:
            raises DuplicateFormatException if format is added with is_default while other
            default exists
            raises DuplicateFormatException if format_name alread exists in the collection
        """
        if is_default and self.default_format:
            raise DuplicateFormatException("A default format already exists for this repeater.")
        elif is_default:
            self.default_format = format_name
        if format_name in self.format_generator_map:
            raise DuplicateFormatException("There is already a Generator with this format name.")

        self.format_generator_map[format_name] = FormatInfo(
            name=format_name,
            label=format_label,
            generator_class=generator_class
        )
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/repeaters/models.py/GeneratorCollection.add_new_format/original