def create_main_saver_node(self, version):
        """Creates the default saver node if there is no created before.

        Creates the default saver nodes if there isn't any existing outputs,
        and updates the ones that is already created
        """

        def output_path_generator(file_format):
            """helper function to generate the output path

            :param file_format:
            :return:
            """
            # generate the data needed
            # the output path
            file_name_buffer = []
            template_kwargs = {}

            # if this is a shot related task set it to shots resolution
            version_sig_name = self.get_significant_name(version)

            file_name_buffer.append(
                '%(version_sig_name)s.001.%(format)s'
            )
            template_kwargs.update({
                'version_sig_name': version_sig_name,
                'format': file_format
            })

            output_file_name = ''.join(file_name_buffer) % template_kwargs

            # check if it is a stereo comp
            # if it is enable separate view rendering
            output_file_full_path = os.path.join(
                version.absolute_path,
                'Outputs',
                version.take_name,
                'v%03d' % version.version_number,
                file_format,
                output_file_name
            ).replace('\\', '/')

            # set the output path
            return '%s' % os.path.normpath(
                output_file_full_path
            ).encode()

        def output_node_name_generator(file_format):
            return '%s_%s' % (self._main_output_node_name, file_format)

        random_ref_id = uuid.uuid4().hex

        output_format_data = [
            {
                'name': 'png',
                'node_tree': {
                    'type': 'Saver',
                    'attr': {
                        'TOOLS_Name': output_node_name_generator('png'),
                    },
                    'input_list': {
                        'Clip': output_path_generator('png'),
                        'ProcessRed': 1,
                        'ProcessGreen': 1,
                        'ProcessBlue': 1,
                        'ProcessAlpha': 0,
                        'OutputFormat': 'PNGFormat',
                        'PNGFormat.SaveAlpha': 0,
                        'PNGFormat.Depth': 1,
                        'PNGFormat.CompressionLevel': 9,
                        'PNGFormat.GammaMode': 0,
                    },
                    'connected_to': {
                        'Input': {
                            'type': 'ColorCurves',
                            'ref_id': random_ref_id,
                            'input_list': {
                                'EditAlpha': 0.0,
                            },
                            'connected_to': {
                                'Input': {
                                    'type': 'CineonLog',
                                    'input_list': {
                                        'Mode': 1,
                                        'RedBlackLevel': 0.0,
                                        'RedWhiteLevel': 1023.0,
                                        'RedFilmStockGamma': 1.0
                                    },
                                    'connected_to': {
                                        'Input': {
                                            'type': 'TimeSpeed',
                                            'attr': {
                                                'TOOLB_PassThrough': True,
                                            },
                                            'input_list': {
                                                'Speed': 12.0/25.0,
                                                'InterpolateBetweenFrames': 0
                                            },
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            {
                'name': 'exr',
                'node_tree': {
                    'type': 'Saver',
                    'attr': {
                        'TOOLS_Name': output_node_name_generator('exr'),
                    },
                    'input_list': {
                        'Clip': output_path_generator('exr'),
                        'ProcessRed': 1,
                        'ProcessGreen': 1,
                        'ProcessBlue': 1,
                        'ProcessAlpha': 0,
                        'OutputFormat': 'OpenEXRFormat',
                        'OpenEXRFormat.Depth': 1,  # 16-bit float
                        'OpenEXRFormat.RedEnable': 1,
                        'OpenEXRFormat.GreenEnable': 1,
                        'OpenEXRFormat.BlueEnable': 1,
                        'OpenEXRFormat.AlphaEnable': 0,
                        'OpenEXRFormat.ZEnable': 0,
                        'OpenEXRFormat.CovEnable': 0,
                        'OpenEXRFormat.ObjIDEnable': 0,
                        'OpenEXRFormat.MatIDEnable': 0,
                        'OpenEXRFormat.UEnable': 0,
                        'OpenEXRFormat.VEnable': 0,
                        'OpenEXRFormat.XNormEnable': 0,
                        'OpenEXRFormat.YNormEnable': 0,
                        'OpenEXRFormat.ZNormEnable': 0,
                        'OpenEXRFormat.XVelEnable': 0,
                        'OpenEXRFormat.YVelEnable': 0,
                        'OpenEXRFormat.XRevVelEnable': 0,
                        'OpenEXRFormat.YRevVelEnable': 0,
                        'OpenEXRFormat.XPosEnable': 0,
                        'OpenEXRFormat.YPosEnable': 0,
                        'OpenEXRFormat.ZPosEnable': 0,
                        'OpenEXRFormat.XDispEnable': 0,
                        'OpenEXRFormat.YDispEnable': 0,
                    },
                    'connected_to': {
                        'ref_id': random_ref_id
                    }
                }
            }
        ]

        # selectively generate output format
        saver_nodes = self.get_main_saver_node()

        for data in output_format_data:
            format_name = data['name']
            node_tree = data['node_tree']

            # now check if a node with the same name exists
            format_node = None
            format_node_name = output_node_name_generator(format_name)
            for node in saver_nodes:
                node_name = node.GetAttrs('TOOLS_Name')
                if node_name.startswith(format_node_name):
                    format_node = node
                    break

            # create the saver node for this format if missing
            if not format_node:
                self.create_node_tree(node_tree)
            else:
                # just update the input_lists
                if 'input_list' in node_tree:
                    input_list = node_tree['input_list']
                    for key in input_list:
                        node_input_list = format_node.GetInputList()
                        for input_entry_key in node_input_list.keys():
                            input_entry = node_input_list[input_entry_key]
                            input_id = input_entry.GetAttrs()['INPS_ID']
                            if input_id == key:
                                value = input_list[key]
                                input_entry[0] = value
                                break

            try:
                os.makedirs(
                    os.path.dirname(
                        output_path_generator(format_name)
                    )
                )
            except __HOLE__:
                # path already exists
                pass
dataset/ETHPy150Open eoyilmaz/anima/anima/env/fusion/__init__.py/Fusion.create_main_saver_node