def new_state(trans, tool, invalid=False):
 state = galaxy.tools.DefaultToolState()
 state.inputs = {}
 if invalid:
  return state
 try:
  return tool.new_state(trans)
 except Exception as e:
  log.debug('Failed to build tool state for tool "%s" using standard method, will try to fall back on custom method: %s', tool.id, e)
 inputs = tool.inputs_by_page[0]
 context = ExpressionContext(state.inputs, parent=None)
 for input in inputs.values():
  try:
   state.inputs[input.name] = input.get_initial_value(trans, context)
  except:
   state.inputs[input.name] = []
 return state

def new_state ( trans , tool , invalid = False ) : state = galaxy . tools . DefaultToolState ( ) state . inputs = { } if invalid : return state try : return tool . new_state ( trans ) except Exception as e : log . debug ( 'Failed to build tool state for tool "%s" using standard method, will try to fall back on custom method: %s' , tool . id , e ) inputs = tool . inputs_by_page [ 0 ] context = ExpressionContext ( state . inputs , parent = None ) for input in inputs . values ( ) : try : state . inputs [ input . name ] = input . get_initial_value ( trans , context ) except : state . inputs [ input . name ] = [ ] return state
create a new defaulttoolstate for the received tool .