コード例 #1
0
ファイル: GtrackComposer.py プロジェクト: brynjagr/gtrackcore
 def _commonFormatVal(self, val, valueType, valueDim):
     valTypeInfo = Gtrack.VAL_TYPE_DICT[valueType]
     
     if valueDim == 'scalar':
         if not isinstance(val, str) and hasattr(val, '__len__') and len(val)==1:
             val = val[0]
         
         if (val == valTypeInfo.missingVal) or (isNan(val) and isNan(valTypeInfo.missingVal)):
             return '.'
         elif isinstance(val, str):
             return self._formatPhraseWithCorrectChrUsage(val, useUrlEncoding=True, notAllowedChars='#.,;=\t')
         else:
             if isinstance(val, bool):
                 return '1' if val == True else '0'
             else:
                 return str(val)
     else:
         return valTypeInfo.delim.join([self._commonFormatVal(valPart, valueType, 'scalar') for valPart in val]) \
                if len(val) != 0 else '.'
コード例 #2
0
ファイル: GtrackComposer.py プロジェクト: gtrack/gtrackcore
    def _commonFormatVal(self, val, valueType, valueDim):
        valTypeInfo = Gtrack.VAL_TYPE_DICT[valueType]

        if valueDim == 'scalar':
            if not isinstance(val, str) and hasattr(
                    val, '__len__') and len(val) == 1:
                val = val[0]

            if (val == valTypeInfo.missingVal) or (isNan(val) and isNan(
                    valTypeInfo.missingVal)):
                return '.'
            elif isinstance(val, str):
                return self._formatPhraseWithCorrectChrUsage(
                    val, useUrlEncoding=True, notAllowedChars='#.,;=\t')
            else:
                if isinstance(val, bool):
                    return '1' if val == True else '0'
                else:
                    return str(val)
        else:
            return valTypeInfo.delim.join([self._commonFormatVal(valPart, valueType, 'scalar') for valPart in val]) \
                   if len(val) != 0 else '.'
コード例 #3
0
 def _commonFormatNumberVal(self, val):
     if isNan(val) or val is None:
         return '.'
     return ('%#.' + str(Config.OUTPUT_PRECISION) + 'g') % val