1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
10 hv
= hex(ord(ch
)).replace('0x', '')
14 # URL escapes the delimiter characters from the output. urllib.quote is not
15 # used because it cannot escape '.'.
18 # Must perform replace on '%' first before the others.
20 result
= result
.replace(c
, '%' + _hex(c
))
23 # Generate a list of command-line switches to enable field trials defined in
24 # fieldtrial_testing_config_*.json.
25 def GenerateArgs(config_path
):
27 with
open(config_path
, 'r') as base_file
:
28 variations
= json
.load(base_file
)
29 except (IOError, ValueError):
34 for trial
, groups
in variations
.iteritems():
37 # For now, only take the first group.
39 trial_group
= [trial
, group
['group_name']]
40 field_trials
.extend(trial_group
)
43 for key
, value
in group
['params'].iteritems():
44 param_list
.append(key
)
45 param_list
.append(value
)
47 # Escape the variables for the command-line.
48 trial_group
= [_escape(x
) for x
in trial_group
]
49 param_list
= [_escape(x
) for x
in param_list
]
50 param
= '%s:%s' % ('.'.join(trial_group
), '/'.join(param_list
))
52 if not len(field_trials
):
54 args
= ['--force-fieldtrials=%s' % '/'.join(field_trials
)]
56 args
.append('--force-fieldtrial-params=%s' % ','.join(params
))
61 print 'Usage: fieldtrial_util.py [base_config_path] [platform_config_path]'
63 print GenerateArgs(sys
.argv
[1], sys
.argv
[2])
65 if __name__
== '__main__':