Convert a type to a str
        If the instance is a Contract, return 'address' instead
168925
def get_type(t):
    
    if isinstance(t, UserDefinedType):
        if isinstance(t.type, Contract):
            return 'address'
    return str(t)
204265
def ts_to_str(jwt_dict):
    
    d = ts_to_dt(jwt_dict)
    for k, v in list(d.items()):
        if isinstance(v, datetime.datetime):
            d[k] = v.isoformat().replace('T', ' ')
    return d
1048627
def to_string(type):
        
        if type == None:
            return "unknown"
        elif type == TypeCode.Unknown:
            return "unknown"
        elif type == TypeCode.String:
            return "string"
        elif type == TypeCode.Integer:
            return "integer"
        elif type == TypeCode.Long:
            return "long"
        elif type == TypeCode.Float:
            return "float"
        elif type == TypeCode.Double:
            return "double"
        elif type == TypeCode.Duration:
            return "duration"
        elif type == TypeCode.DateTime:
            return "datetime"
        elif type == TypeCode.Object:
            return "object"
        elif type == TypeCode.Enum:
            return "enum"
        elif type == TypeCode.Array:
            return "array"
        elif type == TypeCode.Map:
            return "map"
        else:
            return "unknown"
478591
function _str(chunk, type) {
  var b, s = '';
  while(this._offset < chunk.length) {
    b = chunk[this._offset];
    if(b === CR && chunk[this._offset + 1] === LF) {
      this._offset += 2;
      return type === ERR ? new Error(s) : this.simple ? new String(s) : s;
    }
    s += String.fromCharCode(b);
    ++this._offset;
  }
}
138676
def type_str(self, short=False):
        
        if short:
            return javabridge.static_call(
                "weka/core/Attribute", "typeToStringShort", "(Lweka/core/Attribute;)Ljava/lang/String;",
                self.jobject)
        else:
            return javabridge.static_call(
                "weka/core/Attribute", "typeToString", "(Lweka/core/Attribute;)Ljava/lang/String;",
                self.jobject)
200926
def _str_to_type_from_member_module(cls, module_, string):
        

        module_name_short, class_name = string.split(cls._DELIMITER_MODULE)
        members = inspect.getmembers(module_, inspect.ismodule)

        for name, module_member in members:
            if module_name_short == name:
                return getattr(module_member, class_name)

        error_message = cls._ERROR_COULD_NOT_FIND_CLASS.format(string)

        raise exception.BunqException(error_message)
263853
def to_signed(cls, t):
        
        assert isinstance(t, SymbolTYPE)
        t = t.final
        assert t.is_basic
        if cls.is_unsigned(t):
            return {cls.ubyte: cls.byte_,
                    cls.uinteger: cls.integer,
                    cls.ulong: cls.long_}[t]
        if cls.is_signed(t) or cls.is_decimal(t):
            return t
        return cls.unknown
936972
def _convert_property_type(value):
        
        if value in ('true', 'True'):
            return True
        elif value in ('false', 'False'):
            return False
        elif str(value).startswith('{') and str(value).endswith('}'):
            return ast.literal_eval(value)
        else:
            try:
                return int(value)
            except ValueError:
                return value
192630
def get_type(bind):
    
    types = bind.types + [bind.schema.get('format')]
    for type_name in ('date-time', 'date', 'decimal', 'integer', 'boolean',
                      'number', 'string'):
        if type_name in types:
            return type_name
    return 'string'
891624
function stringToGraphQLType(type) {
  switch (type) {
    case 'String':
      return GraphQLString;
    case 'Number':
      return GraphQLFloat;
    case 'Date':
      return GraphQLDate;
    case 'Buffer':
      return GraphQLBuffer;
    case 'Boolean':
      return GraphQLBoolean;
    case 'ObjectID':
      return GraphQLID;
    default:
      return GraphQLGeneric;
  }
}
1202952
def interface_type(self):
        
        value = "if="
        lst = self._attributes.get("if")
        if lst is None:
            value = ""
        else:
            value += "\"" + str(lst) + "\""
        return value
585300
def ToName(param_type):
    
    items = inspect.getmembers(ContractParameterType)

    if type(param_type) is bytes:
        param_type = int.from_bytes(param_type, 'little')

    for item in items:
        name = item[0]
        val = int(item[1].value)

        if val == param_type:
            return name

    return None
91936
def type(self):
        """"""
        if isinstance(self.value, numbers.Number):
            return "number"
        if isinstance(self.value, basestring):
            return "string"
        return "unknown"
1053848
def xlate(self, type):
        
        resolved = type.resolve()
        name = resolved.name
        if type.multi_occurrence():
            name += '[]'
        ns = resolved.namespace()
        if ns[1] == self.wsdl.tns[1]:
            return name
        prefix = self.getprefix(ns[1])
        return ':'.join((prefix, name))
193396
def type_to_string(t):
        """"""
        if t == MemoryElement.TYPE_I2C:
            return 'I2C'
        if t == MemoryElement.TYPE_1W:
            return '1-wire'
        if t == MemoryElement.TYPE_DRIVER_LED:
            return 'LED driver'
        if t == MemoryElement.TYPE_LOCO:
            return 'Loco Positioning'
        if t == MemoryElement.TYPE_TRAJ:
            return 'Trajectory'
        if t == MemoryElement.TYPE_LOCO2:
            return 'Loco Positioning 2'
        return 'Unknown'
123391
def propagate_type_and_convert_call(result, node):
    '''
        
    '''
    calls_value = {}
    calls_gas = {}

    call_data = []

    idx = 0
    # use of while len() as result can be modified during the iteration
    while idx < len(result):
        ins = result[idx]

        if isinstance(ins, TmpCall):
            new_ins = extract_tmp_call(ins, node.function.contract)
            if new_ins:
                new_ins.set_node(ins.node)
                ins = new_ins
                result[idx] = ins

        if isinstance(ins, Argument):
            if ins.get_type() in [ArgumentType.GAS]:
                assert not ins.call_id in calls_gas
                calls_gas[ins.call_id] = ins.argument
            elif ins.get_type() in [ArgumentType.VALUE]:
                assert not ins.call_id in calls_value
                calls_value[ins.call_id] = ins.argument
            else:
                assert ins.get_type() == ArgumentType.CALL
                call_data.append(ins.argument)

        if isinstance(ins, (HighLevelCall, NewContract, InternalDynamicCall)):
            if ins.call_id in calls_value:
                ins.call_value = calls_value[ins.call_id]
            if ins.call_id in calls_gas:
                ins.call_gas = calls_gas[ins.call_id]

        if isinstance(ins, (Call, NewContract, NewStructure)):
            ins.arguments = call_data
            call_data = []

        if is_temporary(ins):
            del result[idx]
            continue

        new_ins = propagate_types(ins, node)
        if new_ins:
            if isinstance(new_ins, (list,)):
                if len(new_ins) == 2:
                    new_ins[0].set_node(ins.node)
                    new_ins[1].set_node(ins.node)
                    del result[idx]
                    result.insert(idx, new_ins[0])
                    result.insert(idx+1, new_ins[1])
                    idx = idx + 1
                else:
                    assert len(new_ins) == 3
                    new_ins[0].set_node(ins.node)
                    new_ins[1].set_node(ins.node)
                    new_ins[2].set_node(ins.node)
                    del result[idx]
                    result.insert(idx, new_ins[0])
                    result.insert(idx+1, new_ins[1])
                    result.insert(idx+2, new_ins[2])
                    idx = idx + 2
            else:
                new_ins.set_node(ins.node)
                result[idx] = new_ins
        idx = idx +1
    return result
1075979
def FromJson(json):
        
        type = ContractParameterType.FromString(json['type'])

        value = json['value']
        param = ContractParameter(type=type, value=None)

        if type == ContractParameterType.Signature or type == ContractParameterType.ByteArray:
            param.Value = bytearray.fromhex(value)

        elif type == ContractParameterType.Boolean:
            param.Value = bool(value)

        elif type == ContractParameterType.Integer:
            param.Value = int(value)

        elif type == ContractParameterType.Hash160:
            param.Value = UInt160.ParseString(value)

        elif type == ContractParameterType.Hash256:
            param.Value = UInt256.ParseString(value)

        # @TODO Not sure if this is working...
        elif type == ContractParameterType.PublicKey:
            param.Value = ECDSA.decode_secp256r1(value).G

        elif type == ContractParameterType.String:
            param.Value = str(value)

        elif type == ContractParameterType.Array:
            val = [ContractParameter.FromJson(item) for item in value]
            param.Value = val

        return param