def _type_from_data(data): """ If type is not given make an educated guess """ if utool.is_bool(data) or data == 'True' or data == 'False': return bool elif utool.is_int(data): return int elif utool.is_float(data): return float else: return str
def cast_into_qt(data): """ Casts python data into a representation suitable for QT (usually a string) """ if SIMPLE_CASTING: if ut.is_str(data): return __STR__(data) elif ut.is_float(data): # qnumber = QString.number(float(data), format='g', precision=8) return locale_float(data) elif ut.is_bool(data): return bool(data) elif ut.is_int(data): return int(data) elif isinstance(data, uuid.UUID): return __STR__(data) elif ut.isiterable(data): return ', '.join(map(__STR__, data)) else: return __STR__(data) if ut.is_str(data): return __STR__(data) elif ut.is_float(data): # qnumber = QString.number(float(data), format='g', precision=8) return locale_float(data) elif ut.is_bool(data): return bool(data) elif ut.is_int(data): return int(data) elif isinstance(data, uuid.UUID): return __STR__(data) elif ut.isiterable(data): return ', '.join(map(__STR__, data)) elif data is None: return 'None' else: return 'Unknown qtype: %r for data=%r' % (type(data), data)
def cast_into_qt(data): """ Casts python data into a representation suitable for QT (usually a string) """ if SIMPLE_CASTING: if ut.is_str(data): return __STR__(data) elif ut.is_float(data): #qnumber = QString.number(float(data), format='g', precision=8) return locale_float(data) elif ut.is_bool(data): return bool(data) elif ut.is_int(data): return int(data) elif isinstance(data, uuid.UUID): return __STR__(data) elif ut.isiterable(data): return ', '.join(map(__STR__, data)) else: return __STR__(data) if ut.is_str(data): return __STR__(data) elif ut.is_float(data): #qnumber = QString.number(float(data), format='g', precision=8) return locale_float(data) elif ut.is_bool(data): return bool(data) elif ut.is_int(data): return int(data) elif isinstance(data, uuid.UUID): return __STR__(data) elif ut.isiterable(data): return ', '.join(map(__STR__, data)) elif data is None: return 'None' else: return 'Unknown qtype: %r for data=%r' % (type(data), data)