コード例 #1
0
ファイル: samDoUtils.py プロジェクト: theomission/TuttleOFX
    def __init__(self, ranges):
        super(ProgressHandle, self).__init__()

        # Get number of frames to compute
        nbFramesToCompute = 0
        for timeRange in ranges:
            nbFramesToCompute += (timeRange._end - timeRange._begin + 1) / timeRange._step
        expectedSize = (nbFramesToCompute if nbFramesToCompute < samUtils.getMaxInt() else 1)

        # Create progress bar
        if clintVersion >= '0.3.5':
            self._progress = progress.Bar(expected_size=expectedSize)
            self._counter = 1
        else:
            self._it = list(range(0, expectedSize+1))
            self._progress = progress.bar(self._it, expected_size=expectedSize)
            self._progress.next()
コード例 #2
0
    def __init__(self, ranges):
        super(ProgressHandle, self).__init__()

        # Get number of frames to compute
        nbFramesToCompute = 0
        for timeRange in ranges:
            nbFramesToCompute += (timeRange._end - timeRange._begin +
                                  1) / timeRange._step
        expectedSize = (nbFramesToCompute
                        if nbFramesToCompute < samUtils.getMaxInt() else 1)

        # Create progress bar
        if clintVersion >= '0.3.5':
            self._progress = progress.Bar(expected_size=expectedSize)
            self._counter = 1
        else:
            self._it = list(range(0, expectedSize + 1))
            self._progress = progress.bar(self._it, expected_size=expectedSize)
            self._progress.next()
コード例 #3
0
ファイル: sam_do.py プロジェクト: EfestoLab/TuttleOFX
    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)
コード例 #4
0
ファイル: sam_do.py プロジェクト: yazici/TuttleOFX
    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)