import string


def substitute_args(tester_config, args):
  """Substitutes the variables in |args| from tester_config properties."""
  substitutions = {
    'os_type': tester_config['os_type'],
    'gpu_vendor_id': '0',
    'gpu_device_id': '0',
  }

  if 'gpu' in tester_config['swarming_dimensions'][0]:
    gpu = tester_config['swarming_dimensions'][0]['gpu'].split(':')
    substitutions['gpu_vendor_id'] = gpu[0]
    substitutions['gpu_device_id'] = gpu[1]

  return [string.Template(arg).safe_substitute(substitutions) for arg in args]