tools/variations/fieldtrial_to_struct.py
def _CreateExperiment(experiment_data,
                      platforms,
                      form_factors,
                      is_low_end_device,
                      invert=False):
  """Creates an experiment dictionary with all necessary information.

  Args:
    experiment_data: An experiment json config.
    platforms: A list of platforms for this trial. This should be
      a subset of |_platforms|.
    form_factors: A list of form factors for this trial. This should be
      a subset of |_form_factors|.
    is_low_end_device: An optional parameter. This can either be True or
      False. None if not specified.
    invert: An optional parameter. If set, inverts the enabled and disabled
      set of experiments. Controlled by a GN flag.

  Returns:
    An experiment dict.
  """
  experiment = {
    'name': experiment_data['name'],
    'platforms': [_PlatformEnumValue(p) for p in platforms],
    'form_factors': [_FormFactorEnumValue(f) for f in form_factors],
  }
  if is_low_end_device is not None:
    experiment['is_low_end_device'] = str(is_low_end_device).lower()
  forcing_flags_data = experiment_data.get('forcing_flag')
  if forcing_flags_data:
    experiment['forcing_flag'] = forcing_flags_data
  min_os_version_data = experiment_data.get('min_os_version')
  if min_os_version_data:
    experiment['min_os_version'] = min_os_version_data
  params_data = experiment_data.get('params')
  if (params_data):
    experiment['params'] = [{'key': param, 'value': params_data[param]}
                          for param in sorted(params_data.keys())];
  enable_features_data = experiment_data.get('enable_features')
  disable_features_data = experiment_data.get('disable_features')
  if enable_features_data or (invert and disable_features_data):
    experiment['enable_features'] = (disable_features_data
                                     if invert else enable_features_data)
  if disable_features_data or (invert and enable_features_data):
    experiment['disable_features'] = (enable_features_data
                                      if invert else disable_features_data)
  override_ui_strings = experiment_data.get('override_ui_strings')
  if override_ui_strings:
    experiment['override_ui_string'] = _ConvertOverrideUIStrings(
        override_ui_strings)
  return experiment
Creates an experiment dictionary with all necessary information.

  Args:
    experiment_data: An experiment json config.
    platforms: A list of platforms for this trial. This should be
      a subset of |_platforms|.
    form_factors: A list of form factors for this trial. This should be
      a subset of |_form_factors|.
    is_low_end_device: An optional parameter. This can either be True or
      False. None if not specified.
    invert: An optional parameter. If set, inverts the enabled and disabled
      set of experiments. Controlled by a GN flag.

  Returns:
    An experiment dict.
  
Creates an experiment dictionary with all necessary information.
Creates an experiment dictionary with all necessary information .
def _CreateExperiment(experiment_data,
                      platforms,
                      form_factors,
                      is_low_end_device,
                      invert=False):
  experiment = {
    'name': experiment_data['name'],
    'platforms': [_PlatformEnumValue(p) for p in platforms],
    'form_factors': [_FormFactorEnumValue(f) for f in form_factors],
  }
  if is_low_end_device is not None:
    experiment['is_low_end_device'] = str(is_low_end_device).lower()
  forcing_flags_data = experiment_data.get('forcing_flag')
  if forcing_flags_data:
    experiment['forcing_flag'] = forcing_flags_data
  min_os_version_data = experiment_data.get('min_os_version')
  if min_os_version_data:
    experiment['min_os_version'] = min_os_version_data
  params_data = experiment_data.get('params')
  if (params_data):
    experiment['params'] = [{'key': param, 'value': params_data[param]}
                          for param in sorted(params_data.keys())];
  enable_features_data = experiment_data.get('enable_features')
  disable_features_data = experiment_data.get('disable_features')
  if enable_features_data or (invert and disable_features_data):
    experiment['enable_features'] = (disable_features_data
                                     if invert else enable_features_data)
  if disable_features_data or (invert and enable_features_data):
    experiment['disable_features'] = (enable_features_data
                                      if invert else disable_features_data)
  override_ui_strings = experiment_data.get('override_ui_strings')
  if override_ui_strings:
    experiment['override_ui_string'] = _ConvertOverrideUIStrings(
        override_ui_strings)
  return experiment
def _CreateExperiment ( experiment_data , platforms , form_factors , is_low_end_device , invert = False ) : experiment = { 'name' : experiment_data [ 'name' ] , 'platforms' : [ _PlatformEnumValue ( p ) for p in platforms ] , 'form_factors' : [ _FormFactorEnumValue ( f ) for f in form_factors ] , } if is_low_end_device is not None : experiment [ 'is_low_end_device' ] = str ( is_low_end_device ) . lower ( ) forcing_flags_data = experiment_data . get ( 'forcing_flag' ) if forcing_flags_data : experiment [ 'forcing_flag' ] = forcing_flags_data min_os_version_data = experiment_data . get ( 'min_os_version' ) if min_os_version_data : experiment [ 'min_os_version' ] = min_os_version_data params_data = experiment_data . get ( 'params' ) if ( params_data ) : experiment [ 'params' ] = [ { 'key' : param , 'value' : params_data [ param ] } for param in sorted ( params_data . keys ( ) ) ] ; enable_features_data = experiment_data . get ( 'enable_features' ) disable_features_data = experiment_data . get ( 'disable_features' ) if enable_features_data or ( invert and disable_features_data ) : experiment [ 'enable_features' ] = ( disable_features_data if invert else enable_features_data ) if disable_features_data or ( invert and enable_features_data ) : experiment [ 'disable_features' ] = ( enable_features_data if invert else disable_features_data ) override_ui_strings = experiment_data . get ( 'override_ui_strings' ) if override_ui_strings : experiment [ 'override_ui_string' ] = _ConvertOverrideUIStrings ( override_ui_strings ) return experiment
Creates an experiment dictionary with all necessary information.
Creates an experiment dictionary with all necessary information .
"""Creates an experiment dictionary with all necessary information.

  Args:
    experiment_data: An experiment json config.
    platforms: A list of platforms for this trial. This should be
      a subset of |_platforms|.
    form_factors: A list of form factors for this trial. This should be
      a subset of |_form_factors|.
    is_low_end_device: An optional parameter. This can either be True or
      False. None if not specified.
    invert: An optional parameter. If set, inverts the enabled and disabled
      set of experiments. Controlled by a GN flag.

  Returns:
    An experiment dict.
  """
An experiment dict.
An experiment dict .
experiment_data
An experiment json config.
An experiment json config .
platforms
A list of platforms for this trial. This should be
a subset of |_platforms|.
A list of platforms for this trial . This should be a subset of |_platforms| .
form_factors
A list of form factors for this trial. This should be
a subset of |_form_factors|.
A list of form factors for this trial . This should be a subset of |_form_factors| .
is_low_end_device
An optional parameter. This can either be True or
False. None if not specified.
An optional parameter . This can either be True or False . None if not specified .
invert
An optional parameter. If set, inverts the enabled and disabled
set of experiments. Controlled by a GN flag.
An optional parameter . If set inverts the enabled and disabled set of experiments . Controlled by a GN flag .