Skip to content

collect_test_selection

CollectTestSelection

Bases: ContextPlugin

testing selection sharing

Source code in client/ayon_flame/plugins/publish/collect_test_selection.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class CollectTestSelection(pyblish.api.ContextPlugin):
    """testing selection sharing
    """

    order = pyblish.api.CollectorOrder
    label = "test selection"
    hosts = ["flame"]
    active = False

    def process(self, context):
        self.log.info(
            "Active Selection: {}".format(ayfapi.CTX.selection))

        sequence = ayfapi.get_current_sequence(ayfapi.CTX.selection)

        self.test_imprint_data(sequence)
        self.test_otio_export(sequence)

    def test_otio_export(self, sequence):
        test_dir = os.path.normpath(
            tempfile.mkdtemp(prefix="test_pyblish_tmp_")
        )
        export_path = os.path.normpath(
            os.path.join(
                test_dir, "otio_timeline_export.otio"
            )
        )
        self.log.debug(export_path)
        otio_timeline = otio_export.create_otio_timeline(sequence)
        otio_export.write_to_file(
            otio_timeline, export_path
        )
        read_timeline_otio = otio.adapters.read_from_file(export_path)

        if otio_timeline != read_timeline_otio:
            raise Exception("Exported timeline is different from original")

        self.log.info(pformat(otio_timeline))
        self.log.info("Otio exported to: {}".format(export_path))

    def test_imprint_data(self, sequence):
        with ayfapi.maintained_segment_selection(sequence) as sel_segments:
            for segment in sel_segments:
                if str(segment.name)[1:-1] == "":
                    continue

                self.log.debug("Segment with AYONData: {}".format(
                    segment.name))

                ayfapi.imprint(segment, {
                    'asset': segment.name.get_value(),
                    'productType': 'render',
                    'productName': 'productMain'
                })