def getListOfSupportedExtension(ofxhImageEffectNodeDescriptor): """ Return list of supported extension from a given plugin descriptor. """ propSupportedExtension = ofxhImageEffectNodeDescriptor.getParamSetProps( ).fetchProperty('TuttleOfxImageEffectPropSupportedExtensions') return samUtils.getListValues(propSupportedExtension)
def _displayNodeHelp(self, nodeFullName, node): """ Display help of a specific node in the command line. """ # NODE self._displayTitle('NODE') with indent(4): puts(colored.green(nodeFullName + ' ' + node.getVersionStr())) # DESCRIPTION self._displayTitle('DESCRIPTION') with indent(4): puts('type: ' + colored.green( tuttle.mapNodeTypeEnumToString(node.getNodeType()))) puts('group: ' + colored.green(node.asImageEffectNode().getPluginGrouping())) puts('\n') puts(node.getProperties().fetchStringProperty( 'OfxPropPluginDescription').getValue()) # PARAMETERS if node.getParams(): self._displayTitle('PARAMETERS') for param in node.getParams(): paramType = param.getParamType() # Skip Group / PushButton / Page params if paramType == 'OfxParamTypeGroup' or paramType == 'OfxParamTypePushButton' or paramType == 'OfxParamTypePage': continue self._displayParamHelp(param) # CLIPS self._displayTitle('CLIPS') for clip in node.getClipImageSet().getClips(): self._displayClipHelp(clip) # SUPPORTED BIT DEPTH if node.getProperties().hasProperty( 'OfxImageEffectPropSupportedPixelDepths'): self._displayTitle('SUPPORTED BIT DEPTH') propBitDepth = node.getProperties().fetchProperty( 'OfxImageEffectPropSupportedPixelDepths') bitDepthValues = samUtils.getListValues(propBitDepth) bitDepthSourceStr = [] bitDepthOutputStr = [] for bitDepthValue in bitDepthValues[:int(len(bitDepthValues) / 2)]: bitDepthSourceStr.append( self._getNbBitsFromOfxBitDepth(bitDepthValue)) for bitDepthValue in bitDepthValues[int(len(bitDepthValues) / 2):]: bitDepthOutputStr.append( self._getNbBitsFromOfxBitDepth(bitDepthValue)) # Print with indent(4): puts('{name!s:10}: [{bitdepth}]'.format( name=colored.green('Source'), bitdepth=', '.join(bitDepthSourceStr))) puts('{name!s:10}: [{bitdepth}]'.format( name=colored.green('Output'), bitdepth=', '.join(bitDepthOutputStr)))
def _displayNodeHelp(self, nodeFullName, node): """ Display help of a specific node in the command line. """ if not node: self.logger.error('Cannot print help of unknown plugin "' + nodeFullName + '".') exit(1) # NODE self._displayTitle('NODE') with indent(4): puts(colored.green(nodeFullName + ' ' + node.getVersionStr())) # DESCRIPTION self._displayTitle('DESCRIPTION') with indent(4): puts('type: ' + colored.green(tuttle.mapNodeTypeEnumToString(node.getNodeType()))) puts('group: ' + colored.green(node.asImageEffectNode().getPluginGrouping())) puts('\n') puts(node.getProperties().fetchStringProperty('OfxPropPluginDescription').getValue()) # PARAMETERS if node.getParams(): self._displayTitle('PARAMETERS') for param in node.getParams(): paramType = param.getParamType() # Skip Group / PushButton / Page params if paramType == 'OfxParamTypeGroup' or paramType == 'OfxParamTypePushButton' or paramType == 'OfxParamTypePage': continue self._displayParamHelp(param) # CLIPS self._displayTitle('CLIPS') for clip in node.getClipImageSet().getClips(): self._displayClipHelp(clip) # SUPPORTED BIT DEPTH if node.getProperties().hasProperty('OfxImageEffectPropSupportedPixelDepths'): self._displayTitle('SUPPORTED BIT DEPTH') propBitDepth = node.getProperties().fetchProperty('OfxImageEffectPropSupportedPixelDepths') bitDepthValues = samUtils.getListValues(propBitDepth) bitDepthSourceStr = [] bitDepthOutputStr = [] for bitDepthValue in bitDepthValues[:int(len(bitDepthValues)/2)]: bitDepthSourceStr.append(self._getNbBitsFromOfxBitDepth(bitDepthValue)) for bitDepthValue in bitDepthValues[int(len(bitDepthValues)/2):]: bitDepthOutputStr.append(self._getNbBitsFromOfxBitDepth(bitDepthValue)) # Print with indent(4): puts('{name!s:10}: [{bitdepth}]'.format( name=colored.green('Source'), bitdepth=', '.join(bitDepthSourceStr))) puts('{name!s:10}: [{bitdepth}]'.format( name=colored.green('Output'), bitdepth=', '.join(bitDepthOutputStr)))
def samDoCompleter(prefix, parsed_args, **kwargs): """ Custom Completer to manage auto competion when looking for openFX nodes. @warning The autocompletion works only for TuttleOFX plugins. """ # preload OFX plugins (to have auto completion of plugins name, their parameters...) tuttle.core().preload(True) # get plugins pluginsId = tuttle.core().getImageEffectPluginCache().getPluginsByID() pluginsStr = [str(id).replace('tuttle.', '') for id in pluginsId] # check last input in command line if len(parsed_args.inputs): lastInput = parsed_args.inputs[-1] # if last input is a plugin, return its parameters if lastInput in pluginsStr: graph = tuttle.Graph() node = graph.createNode('tuttle.' + lastInput) params = node.getParams() paramsStr = [str(param.getScriptName()) for param in params] return paramsStr elif lastInput == '//': return pluginsStr else: for input in reversed(parsed_args.inputs): # if an input is a plugin, get its parameters if input in pluginsStr: graph = tuttle.Graph() node = graph.createNode('tuttle.' + input) params = node.getParams() paramsStr = [ str(param.getScriptName()) for param in params ] # if last input is one of its parameters, return its choices if lastInput in paramsStr: param = node.getParam(lastInput) if param.getProperties().hasProperty( 'OfxParamPropChoiceOption'): propChoiceOption = param.getProperties( ).fetchProperty('OfxParamPropChoiceOption') choicesStr = samUtils.getListValues( propChoiceOption) return choicesStr # else, return its parameters else: return paramsStr # else return available plugins return pluginsStr
def samDoCompleter(prefix, parsed_args, **kwargs): """ Custom Completer to manage auto competion when looking for openFX nodes. @warning The autocompletion works only for TuttleOFX plugins. """ # preload OFX plugins (to have auto completion of plugins name, their parameters...) tuttle.core().preload(True) # get plugins pluginsId = tuttle.core().getImageEffectPluginCache().getPluginsByID() pluginsStr = [str(id).replace('tuttle.', '') for id in pluginsId] # check last input in command line if len(parsed_args.inputs): lastInput = parsed_args.inputs[-1] # if last input is a plugin, return its parameters if lastInput in pluginsStr: graph = tuttle.Graph() node = graph.createNode('tuttle.'+lastInput) params = node.getParams() paramsStr = [str(param.getScriptName()) for param in params] return paramsStr elif lastInput == '//': return pluginsStr else: for input in reversed(parsed_args.inputs): # if an input is a plugin, get its parameters if input in pluginsStr: graph = tuttle.Graph() node = graph.createNode('tuttle.'+input) params = node.getParams() paramsStr = [str(param.getScriptName()) for param in params] # if last input is one of its parameters, return its choices if lastInput in paramsStr: param = node.getParam(lastInput) if param.getProperties().hasProperty('OfxParamPropChoiceOption'): propChoiceOption = param.getProperties().fetchProperty('OfxParamPropChoiceOption') choicesStr = samUtils.getListValues(propChoiceOption) return choicesStr # else, return its parameters else: return paramsStr # else return available plugins return pluginsStr
def _displayParamHelp(self, param): """ Display help of the given OFXParameter. """ paramName = colored.green(param.getScriptName()) if param.getEnabled() and not param.getSecret() and clintVersion >= '0.3.3': paramName.bold = True paramType = param.getParamTypeName() paramHint = param.getHint() paramDefaultValue = None paramChoiceValues = [] paramChoiceLabel = [] paramMinDisplayValue = [] paramMaxDisplayValue = [] paramHasMinMaxValues = False paramIsChoice = False props = param.getProperties() # Choice param if param.getParamType() == 'OfxParamTypeChoice': paramIsChoice = True # Get default choice value if props.hasProperty('OfxParamPropDefault'): propDefault = props.fetchProperty('OfxParamPropDefault') defaultValue = samUtils.getListValues(propDefault) if propDefault.getType() == tuttle.ePropTypeInt: paramDefaultValue = props.getIntProperty('OfxParamPropDefault', 0) # Get choice values if props.hasProperty('OfxParamPropChoiceOption'): propChoiceOption = props.fetchProperty('OfxParamPropChoiceOption') paramChoiceValues = samUtils.getListValues(propChoiceOption) # Get label values if props.hasProperty('OfxParamPropChoiceLabelOption'): propChoiceLabel = props.fetchProperty('OfxParamPropChoiceLabelOption') paramChoiceLabel = samUtils.getListValues(propChoiceLabel) hasLabel = (len(paramChoiceValues) == len(paramChoiceLabel)) # Other param types else: # Get default value if props.hasProperty('OfxParamPropDefault'): propDefault = props.fetchProperty('OfxParamPropDefault') paramDefaultValue = samUtils.getListValues(propDefault) # Get min/max values if props.hasProperty('OfxParamPropDisplayMin'): propDisplayMin = props.fetchProperty('OfxParamPropDisplayMin') propDisplayMax = props.fetchProperty('OfxParamPropDisplayMax') paramMinDisplayValue = samUtils.getListValues(propDisplayMin) paramMaxDisplayValue = samUtils.getListValues(propDisplayMax) # check +inf for i in range(0, len(paramMaxDisplayValue)): if propDisplayMax.getType() == tuttle.ePropTypeInt: if int(paramMaxDisplayValue[i]) >= samUtils.getMaxInt(): paramMaxDisplayValue[i] = 'inf' elif propDisplayMax.getType() == tuttle.ePropTypeDouble: if float(paramMaxDisplayValue[i]) >= samUtils.getMaxInt(): paramMaxDisplayValue[i] = 'inf' # check -inf for i in range(0, len(paramMinDisplayValue)): if propDisplayMax.getType() == tuttle.ePropTypeInt: if int(paramMinDisplayValue[i]) <= -samUtils.getMaxInt()-1: paramMinDisplayValue[i] = '-inf' elif propDisplayMax.getType() == tuttle.ePropTypeDouble: if float(paramMinDisplayValue[i]) <= -samUtils.getMaxInt()-1: paramMinDisplayValue[i] = '-inf' paramHasMinMaxValues = len(paramMinDisplayValue) > 0 and len(paramMinDisplayValue) == len(paramMaxDisplayValue) # Print with indent(4): puts('{paramName!s:50}: {paramType!s:10}'.format( paramName=paramName, paramType=paramType), newline=paramIsChoice) if paramIsChoice: with indent(40): for choiceValue in paramChoiceValues: puts('{choiceValue!s:50} {label}'.format( choiceValue=(colored.yellow(choiceValue) if paramChoiceValues.index(choiceValue) == paramDefaultValue else colored.red(choiceValue)), label=(paramChoiceLabel[paramChoiceValues.index(choiceValue)] if hasLabel else ''))) else: puts('{defaultValue!s:9}'.format( defaultValue=colored.yellow(','.join(paramDefaultValue))), newline=(not paramHasMinMaxValues)) if paramHasMinMaxValues: puts('[{minDisplayValue:5} --> {maxDisplayValue:5}]'.format( minDisplayValue=','.join(paramMinDisplayValue), maxDisplayValue=','.join(paramMaxDisplayValue))) with indent(2): puts(paramHint)
def getListOfSupportedExtension(ofxhImageEffectNodeDescriptor): """ Return list of supported extension from a given plugin descriptor. """ propSupportedExtension = ofxhImageEffectNodeDescriptor.getParamSetProps().fetchProperty('TuttleOfxImageEffectPropSupportedExtensions') return samUtils.getListValues(propSupportedExtension)
def _displayParamHelp(self, param): """ Display help of the given OFXParameter. """ paramName = colored.green(param.getScriptName()) if param.getEnabled( ) and not param.getSecret() and clintVersion >= '0.3.3': paramName.bold = True paramType = param.getParamTypeName() paramHint = param.getHint() paramDefaultValue = None paramChoiceValues = [] paramChoiceLabel = [] paramMinDisplayValue = [] paramMaxDisplayValue = [] paramHasMinMaxValues = False paramIsChoice = False props = param.getProperties() # Choice param if param.getParamType() == 'OfxParamTypeChoice': paramIsChoice = True # Get default choice value if props.hasProperty('OfxParamPropDefault'): propDefault = props.fetchProperty('OfxParamPropDefault') defaultValue = samUtils.getListValues(propDefault) if propDefault.getType() == tuttle.ePropTypeInt: paramDefaultValue = props.getIntProperty( 'OfxParamPropDefault', 0) # Get choice values if props.hasProperty('OfxParamPropChoiceOption'): propChoiceOption = props.fetchProperty( 'OfxParamPropChoiceOption') paramChoiceValues = samUtils.getListValues(propChoiceOption) # Get label values if props.hasProperty('OfxParamPropChoiceLabelOption'): propChoiceLabel = props.fetchProperty( 'OfxParamPropChoiceLabelOption') paramChoiceLabel = samUtils.getListValues(propChoiceLabel) hasLabel = (len(paramChoiceValues) == len(paramChoiceLabel)) # Other param types else: # Get default value if props.hasProperty('OfxParamPropDefault'): propDefault = props.fetchProperty('OfxParamPropDefault') paramDefaultValue = samUtils.getListValues(propDefault) # Get min/max values if props.hasProperty('OfxParamPropDisplayMin'): propDisplayMin = props.fetchProperty('OfxParamPropDisplayMin') propDisplayMax = props.fetchProperty('OfxParamPropDisplayMax') paramMinDisplayValue = samUtils.getListValues(propDisplayMin) paramMaxDisplayValue = samUtils.getListValues(propDisplayMax) # check +inf for i in range(0, len(paramMaxDisplayValue)): if propDisplayMax.getType() == tuttle.ePropTypeInt: if int(paramMaxDisplayValue[i]) >= samUtils.getMaxInt( ): paramMaxDisplayValue[i] = 'inf' elif propDisplayMax.getType() == tuttle.ePropTypeDouble: if float(paramMaxDisplayValue[i] ) >= samUtils.getMaxInt(): paramMaxDisplayValue[i] = 'inf' # check -inf for i in range(0, len(paramMinDisplayValue)): if propDisplayMax.getType() == tuttle.ePropTypeInt: if int(paramMinDisplayValue[i] ) <= -samUtils.getMaxInt() - 1: paramMinDisplayValue[i] = '-inf' elif propDisplayMax.getType() == tuttle.ePropTypeDouble: if float(paramMinDisplayValue[i] ) <= -samUtils.getMaxInt() - 1: paramMinDisplayValue[i] = '-inf' paramHasMinMaxValues = len(paramMinDisplayValue) > 0 and len( paramMinDisplayValue) == len(paramMaxDisplayValue) # Print with indent(4): puts('{paramName!s:50}: {paramType!s:10}'.format( paramName=paramName, paramType=paramType), newline=paramIsChoice) if paramIsChoice: with indent(40): for choiceValue in paramChoiceValues: puts('{choiceValue!s:50} {label}'.format( choiceValue=(colored.yellow(choiceValue + ' (default)') if paramChoiceValues.index(choiceValue) == paramDefaultValue else colored.red(choiceValue)), label=(paramChoiceLabel[paramChoiceValues.index( choiceValue)] if hasLabel else ''))) else: puts('{defaultValue!s:9}'.format( defaultValue=colored.yellow(','.join(paramDefaultValue))), newline=(not paramHasMinMaxValues)) if paramHasMinMaxValues: puts( '[{minDisplayValue:5} --> {maxDisplayValue:5}]'.format( minDisplayValue=','.join(paramMinDisplayValue), maxDisplayValue=','.join(paramMaxDisplayValue))) with indent(2): puts(paramHint)