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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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_print_attributes(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)
        validation_aggregator = ayfapi.ValidationAggregator()
        otio_timeline = otio_export.create_otio_timeline(
            sequence, validation_aggregator=validation_aggregator)

        failed_segments = validation_aggregator.failed_segments
        self.log.info(failed_segments)
        for segment in failed_segments:
            self.log.error(f"Failed segment: {segment.name}")

        otio_export.write_to_file(
            otio_timeline, export_path
        )
        read_timeline_otio = otio.adapters.read_from_file(export_path)

        # Making sure timelines are the same and exporting did not
        # change anything
        if len(str(otio_timeline)) != len(str(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_print_attributes(self, sequence):
        with ayfapi.maintained_segment_selection(sequence) as sel_segments:
            for segment in sel_segments:
                self.log.debug("Segment with AYONData: {}".format(
                    segment.name))

                self.print_segment_properties(segment)

    def print_segment_properties(self, segment):
        """Loop through a PySegment object's attributes and print properties.

        Args:
            segment: A flame.PySegment object
        """
        # Get all attributes
        attributes = dir(segment)

        self.log.debug("Properties of the PySegment object:")
        self.log.debug("-" * 40)
        for attr in attributes:
            if (
                not attr.startswith("__")
                and not callable(getattr(segment, attr))
            ):
                self.log.debug(f"{attr}: {getattr(segment, attr)}")

print_segment_properties(segment)

Loop through a PySegment object's attributes and print properties.

Parameters:

Name Type Description Default
segment

A flame.PySegment object

required
Source code in client/ayon_flame/plugins/publish/collect_test_selection.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def print_segment_properties(self, segment):
    """Loop through a PySegment object's attributes and print properties.

    Args:
        segment: A flame.PySegment object
    """
    # Get all attributes
    attributes = dir(segment)

    self.log.debug("Properties of the PySegment object:")
    self.log.debug("-" * 40)
    for attr in attributes:
        if (
            not attr.startswith("__")
            and not callable(getattr(segment, attr))
        ):
            self.log.debug(f"{attr}: {getattr(segment, attr)}")