MCPcopy Create free account
hub / github.com/OpenAssetIO/OpenAssetIO / print_traits_data

Function print_traits_data

examples/host/simpleResolver/simpleResolver.py:85–115  ·  view source on GitHub ↗

A function that will print out the supplied entity TraitsData.

(data)

Source from the content-addressed store, hash-verified

83
84
85def print_traits_data(data):
86 """
87 A function that will print out the supplied entity TraitsData.
88 """
89 # Note that in real tools, you should avoid working directly with
90 # TraitsData. The industry-specific view classes should be used to
91 # avoid fragile string literals, and ensure consistency.
92 #
93 # For example, the OpenAssetIO-MediaCreation project[1] provides
94 # traits and specifications for common entity types found in
95 # computer graphics. A tool wanting to find the URL for an image
96 # would use the following trait that defines where an entity's
97 # content can be found:
98 #
99 # from openassetio_mediacreation.traits.content import LocatableContentTrait
100 # url = LocatableContentTrait(data).getLocation()
101 #
102 # The low-level API is only used here as this simple example script
103 # has to work with trait ids supplied by users on the command line.
104 #
105 #
106 # [1] https://github.com/OpenAssetIO/OpenAssetIO-MediaCreation
107
108 as_dict = {
109 trait_id: {
110 property_key: data.getTraitProperty(trait_id, property_key)
111 for property_key in data.traitPropertyKeys(trait_id)
112 }
113 for trait_id in data.traitSet()
114 }
115 print(json.dumps(as_dict))
116
117
118#

Callers 1

mainFunction · 0.85

Calls 3

getTraitPropertyMethod · 0.45
traitPropertyKeysMethod · 0.45
traitSetMethod · 0.45

Tested by

no test coverage detected