aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/common.py
diff options
context:
space:
mode:
authorCassidy Burden <cburden@google.com>2016-08-11 15:05:38 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-16 10:33:25 -0700
commit4cc3dd8a3b2ab04cf861d7c71967de0298746cb9 (patch)
treeb032d8da64ed4da9ebbd170598377272cb9ae1a2 /binary_search_tool/common.py
parentb217c8a28be52f90572d26647d38dcfc9e08ce0b (diff)
downloadtoolchain-utils-4cc3dd8a3b2ab04cf861d7c71967de0298746cb9.tar.gz
binary search tool: Run tc_pyformat on all python scripts
REFACTOR WARNING! Run tc_pyformat on all python scripts. TEST=Run unit tests, Android bisection Change-Id: I9624e7be2670bdb29bcdb59404bf9e8c2f7d81c5 Reviewed-on: https://chrome-internal-review.googlesource.com/274615 Commit-Ready: Caroline Tice <cmtice@google.com> Tested-by: Caroline Tice <cmtice@google.com> Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool/common.py')
-rw-r--r--binary_search_tool/common.py210
1 files changed, 111 insertions, 99 deletions
diff --git a/binary_search_tool/common.py b/binary_search_tool/common.py
index 11c6cef1..945270be 100644
--- a/binary_search_tool/common.py
+++ b/binary_search_tool/common.py
@@ -28,8 +28,8 @@ if os.path.isabs(sys.argv[0]):
os.path.dirname(sys.argv[0])))
else:
wdir = os.getcwd()
- utils_pythonpath = os.path.abspath('{0}/{1}/..'.format(
- wdir, os.path.dirname(sys.argv[0])))
+ utils_pythonpath = os.path.abspath('{0}/{1}/..'.format(wdir, os.path.dirname(
+ sys.argv[0])))
sys.path.append(utils_pythonpath)
@@ -78,8 +78,7 @@ class ArgumentDict(collections.OrderedDict):
for key in kwargs:
if key not in self._POSSIBLE_OPTIONS:
- raise TypeError('Invalid option "%s" for argument %s' %
- (key, args[0]))
+ raise TypeError('Invalid option "%s" for argument %s' % (key, args[0]))
self[args] = kwargs
@@ -132,118 +131,131 @@ def StrToBool(str_in):
def _BuildArgsDict(args):
"""Populate ArgumentDict with all arguments"""
- args.AddArgument('-n',
- '--iterations',
- dest='iterations',
- type=int,
- help='Number of iterations to try in the search.',
- default=50)
- args.AddArgument('-i',
- '--get_initial_items',
- dest='get_initial_items',
- help=('Script to run to get the initial objects. '
- 'If your script requires user input '
- 'the --verbose option must be used'))
- args.AddArgument('-g',
- '--switch_to_good',
- dest='switch_to_good',
- help=('Script to run to switch to good. '
- 'If your switch script requires user input '
- 'the --verbose option must be used'))
- args.AddArgument('-b',
- '--switch_to_bad',
- dest='switch_to_bad',
- help=('Script to run to switch to bad. '
- 'If your switch script requires user input '
- 'the --verbose option must be used'))
- args.AddArgument('-I',
- '--test_setup_script',
- dest='test_setup_script',
- help=('Optional script to perform building, flashing, '
- 'and other setup before the test script runs.'))
- args.AddArgument('-t',
- '--test_script',
- dest='test_script',
- help=('Script to run to test the '
- 'output after packages are built.'))
+ args.AddArgument(
+ '-n',
+ '--iterations',
+ dest='iterations',
+ type=int,
+ help='Number of iterations to try in the search.',
+ default=50)
+ args.AddArgument(
+ '-i',
+ '--get_initial_items',
+ dest='get_initial_items',
+ help=('Script to run to get the initial objects. '
+ 'If your script requires user input '
+ 'the --verbose option must be used'))
+ args.AddArgument(
+ '-g',
+ '--switch_to_good',
+ dest='switch_to_good',
+ help=('Script to run to switch to good. '
+ 'If your switch script requires user input '
+ 'the --verbose option must be used'))
+ args.AddArgument(
+ '-b',
+ '--switch_to_bad',
+ dest='switch_to_bad',
+ help=('Script to run to switch to bad. '
+ 'If your switch script requires user input '
+ 'the --verbose option must be used'))
+ args.AddArgument(
+ '-I',
+ '--test_setup_script',
+ dest='test_setup_script',
+ help=('Optional script to perform building, flashing, '
+ 'and other setup before the test script runs.'))
+ args.AddArgument(
+ '-t',
+ '--test_script',
+ dest='test_script',
+ help=('Script to run to test the '
+ 'output after packages are built.'))
# No input (evals to False),
# --prune (evals to True),
# --prune=False,
# --prune=True
- args.AddArgument('-p',
- '--prune',
- dest='prune',
- nargs='?',
- const=True,
- default=False,
- type=StrToBool,
- metavar='bool',
- help=('If True, continue until all bad items are found. '
- 'Defaults to False.'))
+ args.AddArgument(
+ '-p',
+ '--prune',
+ dest='prune',
+ nargs='?',
+ const=True,
+ default=False,
+ type=StrToBool,
+ metavar='bool',
+ help=('If True, continue until all bad items are found. '
+ 'Defaults to False.'))
# No input (evals to False),
# --noincremental (evals to True),
# --noincremental=False,
# --noincremental=True
- args.AddArgument('-c',
- '--noincremental',
- dest='noincremental',
- nargs='?',
- const=True,
- default=False,
- type=StrToBool,
- metavar='bool',
- help=('If True, don\'t propagate good/bad changes '
- 'incrementally. Defaults to False.'))
+ args.AddArgument(
+ '-c',
+ '--noincremental',
+ dest='noincremental',
+ nargs='?',
+ const=True,
+ default=False,
+ type=StrToBool,
+ metavar='bool',
+ help=('If True, don\'t propagate good/bad changes '
+ 'incrementally. Defaults to False.'))
# No input (evals to False),
# --file_args (evals to True),
# --file_args=False,
# --file_args=True
- args.AddArgument('-f',
- '--file_args',
- dest='file_args',
- nargs='?',
- const=True,
- default=False,
- type=StrToBool,
- metavar='bool',
- help=('Whether to use a file to pass arguments to scripts. '
- 'Defaults to False.'))
+ args.AddArgument(
+ '-f',
+ '--file_args',
+ dest='file_args',
+ nargs='?',
+ const=True,
+ default=False,
+ type=StrToBool,
+ metavar='bool',
+ help=('Whether to use a file to pass arguments to scripts. '
+ 'Defaults to False.'))
# No input (evals to True),
# --verify (evals to True),
# --verify=False,
# --verify=True
- args.AddArgument('--verify',
- dest='verify',
- nargs='?',
- const=True,
- default=True,
- type=StrToBool,
- metavar='bool',
- help=('Whether to run verify iterations before searching. '
- 'Defaults to True.'))
- args.AddArgument('-N',
- '--prune_iterations',
- dest='prune_iterations',
- type=int,
- help='Number of prune iterations to try in the search.',
- default=100)
+ args.AddArgument(
+ '--verify',
+ dest='verify',
+ nargs='?',
+ const=True,
+ default=True,
+ type=StrToBool,
+ metavar='bool',
+ help=('Whether to run verify iterations before searching. '
+ 'Defaults to True.'))
+ args.AddArgument(
+ '-N',
+ '--prune_iterations',
+ dest='prune_iterations',
+ type=int,
+ help='Number of prune iterations to try in the search.',
+ default=100)
# No input (evals to False),
# --verbose (evals to True),
# --verbose=False,
# --verbose=True
- args.AddArgument('-V',
- '--verbose',
- dest='verbose',
- nargs='?',
- const=True,
- default=False,
- type=StrToBool,
- metavar='bool',
- help='If True, print full output to console.')
- args.AddArgument('-r',
- '--resume',
- dest='resume',
- action='store_true',
- help=('Resume bisection tool execution from state file.'
- 'Useful if the last bisection was terminated '
- 'before it could properly finish.'))
+ args.AddArgument(
+ '-V',
+ '--verbose',
+ dest='verbose',
+ nargs='?',
+ const=True,
+ default=False,
+ type=StrToBool,
+ metavar='bool',
+ help='If True, print full output to console.')
+ args.AddArgument(
+ '-r',
+ '--resume',
+ dest='resume',
+ action='store_true',
+ help=('Resume bisection tool execution from state file.'
+ 'Useful if the last bisection was terminated '
+ 'before it could properly finish.'))