def _to_python(self, file=None, mode=None,
                   transient_name=None, original_name=None):

        file_manager = self.file_manager

        if not self._is_empty(file):
            file = file_manager.create_transient(file.file, file.filename)
        else:
            file = None

        if mode == 'empty':
            if not file and self.required:
                raise convs.ValidationError(self.error_required)

        elif mode == 'transient':
            if not original_name:
                logger.warning('Missing original_name for FileField')
            if not transient_name:
                logger.warning('Missing transient_name for FileField '
                               'in mode "transient"')
                raise convs.ValidationError(self.error_hacking)

            try:
                transient_file = file_manager.get_transient(transient_name)
            except __HOLE__:
                raise convs.ValidationError(self.error_lost)

            if file:
                file_manager.delete(transient_file)
            else:
                file = transient_file

        elif mode == 'existing':
            if not file:
                return self._existing_value

        return file
dataset/ETHPy150Open SmartTeleMax/iktomi/iktomi/unstable/forms/files.py/FileFieldSetConv._to_python