def _GenerateActionsForMSBuild(spec, actions_to_add):
 sources_handled_by_action = OrderedSet()
 actions_spec = []
 for (primary_input, actions) in actions_to_add.iteritems():
  inputs = OrderedSet()
  outputs = OrderedSet()
  descriptions = []
  commands = []
  for action in actions:
   inputs.update(OrderedSet(action['inputs']))
   outputs.update(OrderedSet(action['outputs']))
   descriptions.append(action['description'])
   cmd = action['command']
   if action.get('msbuild_use_call', True):
    cmd = ('call ' + cmd)
   commands.append(cmd)
  description = ', and also '.join(descriptions)
  command = '\r\n'.join([(c + '\r\nif %errorlevel% neq 0 exit /b %errorlevel%') for c in commands])
  _AddMSBuildAction(spec, primary_input, inputs, outputs, command, description, sources_handled_by_action, actions_spec)
 return (actions_spec, sources_handled_by_action)

def _GenerateActionsForMSBuild ( spec , actions_to_add ) : sources_handled_by_action = OrderedSet ( ) actions_spec = [ ] for ( primary_input , actions ) in actions_to_add . iteritems ( ) : inputs = OrderedSet ( ) outputs = OrderedSet ( ) descriptions = [ ] commands = [ ] for action in actions : inputs . update ( OrderedSet ( action [ 'inputs' ] ) ) outputs . update ( OrderedSet ( action [ 'outputs' ] ) ) descriptions . append ( action [ 'description' ] ) cmd = action [ 'command' ] if action . get ( 'msbuild_use_call' , True ) : cmd = ( 'call ' + cmd ) commands . append ( cmd ) description = ', and also ' . join ( descriptions ) command = '\r\n' . join ( [ ( c + '\r\nif %errorlevel% neq 0 exit /b %errorlevel%' ) for c in commands ] ) _AddMSBuildAction ( spec , primary_input , inputs , outputs , command , description , sources_handled_by_action , actions_spec ) return ( actions_spec , sources_handled_by_action )
add actions accumulated into an actions_to_add .