MCPcopy Create free account
hub / github.com/ImageEngine/cortex / __init__

Method __init__

python/IECore/BasicPreset.py:72–123  ·  view source on GitHub ↗
( self, pathOrDataOrParameterised, rootParameter=None, parameters=(), referenceData=False )

Source from the content-addressed store, hash-verified

70 ## copies any parameter values so the preset is not dependent on the source
71 ## parameters state at the time of application.
72 def __init__( self, pathOrDataOrParameterised, rootParameter=None, parameters=(), referenceData=False ) :
73
74 self._header = None
75 self._data = None
76 self._cob = None
77
78 IECore.Preset.__init__( self )
79
80 self.parameters().addParameters(
81
82 [
83 IECore.BoolParameter(
84 name = "overwriteMatchingComponents",
85 description = "When off, the preset will always append items to a " + \
86 "ClassVectorParameter, otherwise, it will replace the existing " + \
87 "classes with the same names, if they don't match the preset. " + \
88 "This does not affect and parameter values, these are always set " + \
89 "to match the preset.",
90 defaultValue = False
91 ),
92 ]
93 )
94
95 if isinstance( pathOrDataOrParameterised, str ) :
96
97 self._cob = pathOrDataOrParameterised
98
99 elif isinstance( pathOrDataOrParameterised, IECore.CompoundObject ) :
100
101 self._data = pathOrDataOrParameterised
102
103 elif hasattr( pathOrDataOrParameterised, "parameters" ):
104
105 data = IECore.CompoundObject()
106
107 if rootParameter is None:
108 rootParameter = pathOrDataOrParameterised.parameters()
109
110 BasicPreset._grabHierarchy( data, rootParameter, parameters )
111
112 # We need to prune any class entries without parameters, so that
113 # we don't meddle with classes the user asked us not to copy parameters for.
114 BasicPreset._pruneHierarchy( data )
115
116 if referenceData:
117 self._data = data
118 else:
119 self._data = data.copy()
120
121 else :
122
123 raise ValueError( "IECore.BasicPreset.__init__: Unsupported object passed: %s." % pathOrDataOrParameterised )
124
125 ## \return a dictionary of metatdata about the preset. BasicPresets
126 ## provide the following keys, when a preset has been saved to disk.

Callers

nothing calls this directly

Calls 6

addParametersMethod · 0.80
CompoundObjectMethod · 0.80
_grabHierarchyMethod · 0.80
_pruneHierarchyMethod · 0.80
parametersMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected