Converts the value from a database value into a Python value.
504063
def to_python(self, value: Union[Dict[str, int], int, None]) -> LocalizedIntegerValue:
        """"""

        db_value = super().to_python(value)
        return self._convert_localized_value(db_value)
445650
def get_db_prep_value(self, value, connection=None, prepared=False):
        
        if not value:
            return
        if prepared:
            return value
        else:
            assert(isinstance(value, list) or isinstance(value, tuple))
            return self.separator.join([unicode(s) for s in value])
139459
def to_python(self, value):
        """"""
        cache = None
        if value is None:
            return None

        if isinstance(value, DataDescriptor):
            return value
        elif isinstance(value, dict):
            # Allow pre-hydrated data objects.
            cache = value
            try:
                value = cache['__id']
            except KeyError:
                raise ValidationError("dictionary must contain an '__id' element")
        elif not isinstance(value, int):
            raise ValidationError("field must be a DataDescriptor, data object primary key or dict")

        return DataDescriptor(value, self, cache)
952050
def clean(self, value):
        
        value = self.to_python(value)
        self.validate(value)
        return value
525695
def _PythonValueToJsonValue(py_value):
    """"""
    if py_value is None:
        return JsonValue(is_null=True)
    if isinstance(py_value, bool):
        return JsonValue(boolean_value=py_value)
    if isinstance(py_value, six.string_types):
        return JsonValue(string_value=py_value)
    if isinstance(py_value, numbers.Number):
        if isinstance(py_value, six.integer_types):
            if _MININT64 < py_value < _MAXINT64:
                return JsonValue(integer_value=py_value)
        return JsonValue(double_value=float(py_value))
    if isinstance(py_value, dict):
        return JsonValue(object_value=_PythonValueToJsonObject(py_value))
    if isinstance(py_value, collections.Iterable):
        return JsonValue(array_value=_PythonValueToJsonArray(py_value))
    raise exceptions.InvalidDataError(
        'Cannot convert "%s" to JsonValue' % py_value)
1026927
def to_db(self, value):
        

        # ensure value is valid
        self.validate(value)

        assert isinstance(value, list)
        value = list(value)
        for i, v in enumerate(value):
            value[i] = self.value_to_db(v)

        # return result
        assert isinstance(value, list)
        return value
269283
def convert_value(self, value):
        """"""
        if isinstance(value, str):
            value = value.replace(self.separator, '')
            if self.decimal_point not in value:
                return int(value)
            else:
                return float(value.replace(self.decimal_point, '.'))
        elif self.int_to_float:
            return float(value)
        else:
            return value
326366
def to_python(self, value):
        
        if self.blank and not value:
            return {}
        value = value or '{}'
        if isinstance(value, six.binary_type):
            value = six.text_type(value, 'utf-8')
        if isinstance(value, six.string_types):
            try:
                # with django 1.6 i have '"{}"' as default value here
                if value[0] == value[-1] == '"':
                    value = value[1:-1]

                return json.loads(value)
            except Exception as err:
                raise ValidationError(str(err))
        else:
            return value
1101986
def to_python(self, value):
        
        assert isinstance(value, list)

        # convert every value in list
        value = list(value)
        for i, v in enumerate(value):
            value[i] = self.value_to_python(v)

        # return result
        return value
206399
def value_to_db(self, value):
        

        assert isinstance(value, str)

        array = value.split("-")
        length = len(array) - 3

        assert length >= 0
        assert array[0] == 'S'

        array = array[1:2] + [length, 0, 0, 0, 0, 0] + array[2:]
        array = [int(i) for i in array]

        return struct.pack('<bbbbbbbb' + 'I' * length, *array)
669165
def _convert_value(self, column, value):
        ''''''

        if isinstance(value, GObject.Value):
            return value
        return GObject.Value(self.get_column_type(column), value)
418974
def to_python(self, value):
        ''''''
        if isinstance(value, Seconds):
            return value
        if value in self.empty_values:
            return None
        return self.parse_seconds(value)
420516
def convert(self, value):
        
        if self._type is str:
            return str(value)
        elif self._type is int:
            try:
                return int(value)
            except (UnicodeError, ValueError):
                raise WorkflowArgumentError('Cannot convert {} to int'.format(value))
        elif self._type is float:
            try:
                return float(value)
            except (UnicodeError, ValueError):
                raise WorkflowArgumentError('Cannot convert {} to float'.format(value))
        elif self._type is bool:
            if isinstance(value, bool):
                return bool(value)
            value = value.lower()
            if value in ('true', '1', 'yes', 'y'):
                return True
            elif value in ('false', '0', 'no', 'n'):
                return False
            raise WorkflowArgumentError('Cannot convert {} to bool'.format(value))
        else:
            return value
1364813
def dbStore(self, typ, py_value):
        
        # convert base types to work in the database
        if isinstance(py_value, (list, tuple, set)):
            py_value = tuple((self.dbStore(x) for x in py_value))
        elif isinstance(py_value, orb.Collection):
            py_value = py_value.ids()
        elif isinstance(py_value, orb.Model):
            py_value = py_value.id()

        return py_value
979618
def process_column(self, idx, value):
        ""
        if value is not None:
            value = str(value).decode(self.encoding)
        return value
1338946
def to_python(self, value):
        """"""

        # ``is_required`` is already checked in ``validate``.
        if value is None:
            return None

        # Validate the type.
        if not isinstance(value, six.string_types):
            raise forms.ValidationError(
                "Invalid value type (should be a string).",
                code='invalid-choice-type',
            )

        # Get the constant from the choices object, raising if it doesn't exist.
        try:
            final = getattr(self.choices, value)
        except AttributeError:
            available = '[%s]' % ', '.join(self.choices.constants)
            raise forms.ValidationError(
                "Invalid value (not in available choices. Available ones are: %s" % available,
                code='non-existing-choice',
            )

        return final
766943
def from_value(self, value):
        
        if value is None:
            sql_type = NVarCharType(size=1)
        else:
            sql_type = self._from_class_value(value, type(value))
        return sql_type