def persist_uploads(params):
 if ('files' in params):
  new_files = []
  for upload_dataset in params['files']:
   f = upload_dataset['file_data']
   if isinstance(f, FieldStorage):
    assert (not isinstance(f.file, StringIO))
    assert (f.file.name != '<fdopen>')
    local_filename = util.mkstemp_ln(f.file.name, 'upload_file_data_')
    f.file.close()
    upload_dataset['file_data'] = dict(filename=f.filename, local_filename=local_filename)
   elif ((type(f) == dict) and ('local_filename' not in f)):
    raise Exception('Uploaded file was encoded in a way not understood by Galaxy.')
   if (upload_dataset['url_paste'] and (upload_dataset['url_paste'].strip() != '')):
    (upload_dataset['url_paste'], is_multi_byte) = datatypes.sniff.stream_to_file(StringIO(upload_dataset['url_paste']), prefix='strio_url_paste_')
   else:
    upload_dataset['url_paste'] = None
   new_files.append(upload_dataset)
  params['files'] = new_files
 return params

def persist_uploads ( params ) : if ( 'files' in params ) : new_files = [ ] for upload_dataset in params [ 'files' ] : f = upload_dataset [ 'file_data' ] if isinstance ( f , FieldStorage ) : assert ( not isinstance ( f . file , StringIO ) ) assert ( f . file . name != '<fdopen>' ) local_filename = util . mkstemp_ln ( f . file . name , 'upload_file_data_' ) f . file . close ( ) upload_dataset [ 'file_data' ] = dict ( filename = f . filename , local_filename = local_filename ) elif ( ( type ( f ) == dict ) and ( 'local_filename' not in f ) ) : raise Exception ( 'Uploaded file was encoded in a way not understood by Galaxy.' ) if ( upload_dataset [ 'url_paste' ] and ( upload_dataset [ 'url_paste' ] . strip ( ) != '' ) ) : ( upload_dataset [ 'url_paste' ] , is_multi_byte ) = datatypes . sniff . stream_to_file ( StringIO ( upload_dataset [ 'url_paste' ] ) , prefix = 'strio_url_paste_' ) else : upload_dataset [ 'url_paste' ] = None new_files . append ( upload_dataset ) params [ 'files' ] = new_files return params
turn any uploads in the submitted form to persisted files .